quickwit-oss / tantivy-py

Python bindings for Tantivy
MIT License
292 stars 63 forks source link

Adding document based scoring #51

Open AliFlux opened 2 years ago

AliFlux commented 2 years ago

Hi,

Is there a way to score some documents higher than others? Something like weight in whoosh?

For example: In an ecommerce site, we can have a popularity field for each items. And when user searches for something, the popular documents appear on top.

This is already implemented in tantivy core repo: https://docs.rs/tantivy/0.10.3/tantivy/collector/struct.TopDocs.html#example

I understand that bringing the callback from rust to python may make it slower. Therefore the python interface should be pretty simple. E.g. searcher.search(query, weight_by='popularity')

alex-au-922 commented 7 months ago

@AliFlux What about adding BooleanQuery in the query, where popular items are additionally added some scores?