I use MongoDB and have a collection with about 100,000 entries.
Records contain the following data:
{"page": "page1", "user_count": 1400} {"page": "page2", "user_count": 1100} {"page": "page3", "user_count": 900} ...
I want to infer the ranking of entries according to user_count, for example:
#1 - page1 #2 - page2 #3 - page3 ...
... so far so good. I can just use a loop counter if I just output a sorted list. :)
But I also have to support various search queries. So, for example, I get 20 results and want to show on what ranking the results are. How:
#432 - page1232 #32 - page223 #345 - page332 ...
What is the best way to do this? I do not want to keep the rating in the collection, as the collection is constantly changing. I tried to solve it using the search dictionary, which I built on the fly, but it was very slow. Does MongoDB have special features for such cases that might help?
source share