sanju
sanju

Reputation: 113

SOLR - Different score to different words in a multi word search query

I am using SOLR with mongoDB in one of my projects for search. I must say, SOLR is very powerful. Currently, I am looking for a method to set different scores for different keywords if query is multi word.

e.g. If a user searches of black doll house

the weightage of black should be greater than doll and weightage of doll should be greater than house.

black > doll > house

Is it possible to implement this in SOLR. If yes, how?

Upvotes: 0

Views: 511

Answers (2)

Vinod
Vinod

Reputation: 1953

Did you try boosting the terms in the query. you can specify different boost value for a term in the query. example: if you transform your query to :

textfeild:black^6 textfeild:doll^5 textfeild:house^2

you get results with top documents will be matched for black, next black, next with house.

it multiplies term weight with boost value. here black with 6, doll with 5 and house with 2.

Upvotes: 0

MatsLindh
MatsLindh

Reputation: 52792

You can give a separate weight to each term in the standard lucene query syntax (searching in a field named text):

text:black^10 text:doll^5 text:house

This will give black ten times as much weight as house, and doll five times a much weight as house, but only half the weight of black. You'll have to tweak the weights to get the results you're looking for. If you want to use the regular text in the q= field with (e)dismax as the query parser, you can use bq to add apply these boosts separately from the query itself.

Upvotes: 1

Related Questions