简体   繁体   中英

How can I change the score of a document based on the *Price* of a field (say, “popularity”) in solr

How to boost record depend on any field in Solr.

Reference link : https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_increase_the_score_for_specific_documents

But I am not getting clearlly in my case.

I have some record after search

在此处输入图片说明

How to get Id : 5,8,17 and 1 up some step not top of the list, just boost some step.Because it's price is higher.

It's my row query ;

select?mm=100%25&version=2.2&q=(book)&defType=edismax&spellcheck.q=(book)&qf=Price^10+Name^1+nGramContent&spellcheck=true&stats=true&facet.mincount=1&facet=true&spellcheck.collate=true&stats.field=Price&rows=50&indent=on&wt=json&fl=Id,score,Price

Please help me.

Thanks!

The qf parameters are for hits in the field and will not affect the ranking unless the query produces a hit in the field. Your example would require you to search for the price (and not book ) for anything to be boosted by the qf=Price^10 argument.

The FAQ you've linked to answers your question, just not the question you've referenced: How can I change the score of a document based on the value of a field . From the example (replace popularity with price for your case):

# simple boosts by popularity
defType=dismax&qf=text&q=supervillians&bf=popularity
q={!boost b=popularity}text:supervillians

# boosts based on complex functions of the popularity field
defType=dismax&qf=text&q=supervillians&bf=sqrt(popularity)
q={!boost b=sqrt(popularity)}text:supervillians

edismax makes the {!boost} (multiplicative boost) available as the boost= parameter as well, so you can reference it directly instead of having it in your query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM