开发者

In Solr, can I apply a boost to each term in a phrase?

Usi开发者_如何学运维ng Solr, if I have a phrase:

"The quick brown fox jumped over the lazy dog."

Can I apply my own weighting to these words at index-time?

Something like this:

"The^1 quick^2 brown^2 fox^3 ..." etc

And, then, I'd like to have those numbers influence the score.

Thanks!


You might wanna check payloads: Lucid or ultramagnus. You can add weights to terms at index time this way.


You can use boost query. So if you are searching on title field, you can query saying bq=(title:The)^1&bq=(title:quick)^2&bq=(title:brown)^2 and so on...


You should be able to do so the way you have written it:

http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boosting a Term

Boosting a Term Lucene provides the relevance level of matching documents based on the terms found. To boost a term use the caret, "^", symbol with a boost factor (a number) at the end of the term you are searching. The higher the boost factor, the more relevant the term will be.

Boosting allows you to control the relevance of a document by boosting its term. For example, if you are searching for

jakarta apache and you want the term "jakarta" to be more relevant boost it using the ^ symbol along with the boost factor next to the term. You would type:

jakarta^4 apache This will make documents with the term jakarta appear more relevant. You can also boost Phrase Terms as in the example:

"jakarta apache"^4 "Apache Lucene" By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜