I'm looking for suggestion on how to improve my current prototype. Basically I'm happy with my search results based on text matching (analyzer). Now however I would also like to boost results if they are popular.
Let's say my search result contains documents in the following order name (score):
- League of Legends (102.34)
- Apex Legends (101.12)
- EVE Legens (101.09)
- Legends of Azeroth (101.01)
However today Apex Legends had a new update and a lot of people are searching for it I would like it moved to the top. Legends of Azeroth also had a lot of searches yesterday so I would like to boost it up as well.
What I'm currently doing is I have two indices one for data and one for hits. I return a result set to the first user as shown above the user in their app clicks on one of the results in this case Apex Legends and when they do that they call my API which than stores a new entry in the hits indice.
The entry is basically { "id": "...", "timestamp": ... }
.
Now when the second user does the similar/same search i first do a query on data indice and I get the result as above. Than I take ID's of top 3-5 result entries and do a query on hit indice and I sort the result set by the number of hits they had in the last 12-24h.
This however is a bit on a messy/slow side. As I can't just push documents directly out of ES to user but have a java method in between which needs to parse the results do another query, sort the results and than serialize and sent them to the user.
Alternative idea is I add a property to all my documents called trending
. Then each time user selects document as search result I increase this trending
value. I can than use field value factor to boost by this value.
However each day I would have to refresh my indice and set all these values back down to 0 or half. My indice is pretty massive so this would take quite some time. And on top of that I would not be able to get data such as how popular was some hit during certain time of the year/month/week/day as I would with a hit indice.
Any suggestions are very welcome.