Solr search based on list of terms. Order by max(score) for each term
I am trying to query a solr server in order to obtain the most relevant开发者_如何学Go results for a list of terms.
For example i have the list of words "nokia", "iphone", "charger"
My schema contains the following data:
nokia iphone nokia iphone otherwords nokia white iphone whiteIf I run a simple query like q=nokia OR iphone OR charger i get "nokia iphone otherwords" as the most relevant result (because it contains more query terms)
I would like to get "nokia" or "iphone" or "iphone white" as first results, because for each individual term they would be the most relevant.
In order to obtain the correct list i would do a query for each term, then aggregate the results and order them based on the maximum score.
Can I make this query in one request?
I think you should look at the "coord". From the SolrRelevancyFAQ:
coord is the coordination factor - if there are multiple terms in a query, the more terms that match, the higher the score
You could write your own Similarity subclass to ignore the coord or only take the highest value when scoring.
There might be other ways too, you could ask in the solr-users mailing list.
This might also help: comparing lucene scores across queries
Seems like you should execute 3 separate searches to me
精彩评论