Reputation: 1883
I want boost at query time all documents that have value user_id=2. Basically I want on the top of my results all the documents belonged to a specific user. After looking at some Solr resources I ended up writing a query like, but it is not working properly.
/solr/public-main/select?q={!boost b=if(div(155623,user_id),2,1)}sometext&wt=json&indent=true&debugQuery=true
Any hints?
Thanks
Upvotes: 1
Views: 734
Reputation: 603
One option is to have a function query with fl=x,y,userexists:exists(query({!v='user_id:2'})) and then u can sort by userexists
and then by score field.
Upvotes: 1
Reputation: 52902
You don't need to use the boost with a dynamic boost. Apply a boost query which will boost all the documents that match the query: bq=user_id:2^4
. Adjust 4
to a suitable boost value depending on the rest of your boosts (if any in q
or qf
).
Upvotes: 2