RediSearch
RediSearch copied to clipboard
Add weighting for numericFields
It would be nice to implement search, which can weight NumericField
s.
In our case, we're building an appstore like application and want to give heigher ratings to apps, that have more downloads. But if we only by downloads, we end up loosing the weighting from the search and irrelevant apps, with many apps end up dominating the search results.
Notice when you add a document you can also set its SCORE
, if the SCORE
will be relative to the downloads I think you'll be able to achieve what you're trying to achieve.
Check SCORE_FIELD
in FT.CREATE documentation.
Seems like this is not supported by redis-py via create_index? https://redis-py.readthedocs.io/en/stable/_modules/redis/commands/search/commands.html?highlight=score#
@razzeee you can achieve this with FT.AGGREGATE. Use APPLY with whatever formula you wish and then sort by the result.
I'm not sure how to get the weight
or the score
on aggregate, to be able to mash that up with a weighting of the downloads. And for the weighting I would need the max downloads, which doesn't seem to be a thing via apply as far as I tested/found docs?
.apply(downloads_last_month_max="MAX(downloads_last_month)")