javascript - Getting the index of an object in an ordered list in Firebase -
I am creating a leaderboard using Firebase. In the leaderboard the player's position is tracked using the firebase preference system.
At some point in the performance of my program, I need to know what is the position of the user given in the leaderboard. I have thousands of users, so to find something with a single ID, running through them all (thus giving me an indication) is not really an option.
Is there any definite method
edit : I am trying to find out the following: If you process tens Whether there are hundreds of elements and there is no objection to taking any bandwidth hits, look for the answer to If you are processing the resources of the records, then you have to follow the stated approach, the answer to the Torchlight is a convenient node script that syncs flexible search with firebase data. this As a writing, torchlight does not give you a way to do an elastic search, you only document and not document itself Which uses a simple one-line fix to add this functionality if you do not stop when you read this reply, then just change your copy / manually fork torch . The query that I sent through fireworks: Change the The response will look like this:
/ - --- Leaderboard -------- user4 {...} -------- user1 {...} -------- user3 {...} & lt; - Is there a snapshot of User3's index, user 3? --------...
BUT .
peperin in theory. Description of the following answer.
Step 1: Setup flashlight to your leaderboard with elastic search
Step 2: Modify the flashlight so that you allow the query option to ElasticSearch
Step 3: Query!
{index: 'firebase', type: 'all time', query: {"filtered": { "Query": {"match_all": {}}, "filter": {"range": {"points": {"gte": minPoints}}}}}, option: {"search_type": "count"} };
numeral with the name of the field tracking points for your users, and
the minimum point with the number of that user's number You are interested in the rank.
{max_core: 0, total: 2}
total Is the number of users who have the same or more number of points - in other words, the user's rank!
Comments
Post a Comment