blevesearch / bleve

A modern text/numeric/geo-spatial/vector indexing library for go
Apache License 2.0
10.09k stars 686 forks source link

ability to have custom scoring function #396

Open mschoch opened 8 years ago

mschoch commented 8 years ago

provide your own go function, be able to use other indexed/stored values

@mattetti

mschoch commented 7 years ago

I'm moving this to 1.x. We've come a long way without this, I don't think it should hold up a 1 .0 release.

I'm going to initially target it for 1.x as I think it could be done without any breaking changes to the API (by introducing a custom score Query which wraps other queries). But, if we find it requires API changes it could move to 2.0 later.

CGamesPlay commented 4 years ago

I wanted to accomplish this, and searching through issues doesn't seem to turn up anything useful, so I decided to add this note showcasing my workaround for this issue. The basic process is to:

An implementation providing a "freshness" score can be seen in this gist.

Downsides to this workaround: you have to get into the internals of the index to read the values; my reference implementation does not appear in query explanations (adding support for this would not be hard).

rgalanakis commented 2 years ago

Hi @CGamesPlay , I took your Gist and went a bit further generalizing it into a BoostingQuery, in this Gist. Hopefully this helps some folks who have similarly complex boost requirements (in my case, I needed to boost if a facet is a certain value).

Are there negative performance impacts from this sort of booster/weighter? Obviously it's faster if it doesn't have to run, but is there anything I should be looking out for?