0
votes

I am using Apache Solr 8 with products as documents. Each document includes sales within the last X days that I want to boost, as well as a title and other fields.

Say productA has been sold 5 times, I want to boost it with score+10; a productB has been sold 50 times, I want to boost the score by 30.

I tried to use a boostFunction that looks like (edismax query parser)

q=Coffee&qf=title&bf=if(lt(sales,5),10,if(lt(sales,50),30))

Solr now returns documents that have nothing to do with my "Coffee"-Query but just match the boostfunction. There are even results with score "0". E.g.

Rank;Score;Sales;Title
1;58.53;55;Coffee big
2;38.11;50;Coffee
3;30;55;Tea

Any idea to get rid of those "only boost function"-matches?

1

1 Answers

1
votes

Found the answer!

My Query-Fields actually included boostings like

&qf=title^2 longDescription^0 whatever^0...

Instead of excluding the results found in those 0-boosted fields, solr adds them and matches with - well score 0.

When I remove the 0-boostings, everything works as intended.