0
votes

How to boost some particular words in lucene index?

For e.g. I have a list of items:

"lucene in action"
"solr in action"
"solr in action book"
"building search applications"
"building search applications book"

I consider the word "book" as not important and would like to down vote it. I would not like to use filter to remove the word completely from search results as it is still might be useful. Some book might have a word book in it's name (for e.g. "book of mormon").

Currently, I use

new StandardAnalyzer(version)

and store fields as

new TextField("name", name, Field.Store.YES)

Ideally, I would like to have a dictionary with a list of terms to boost and to provide it to lucene. I know that I can boost on search if I break the request to terms (like "lucene" AND "book"^0.5), but it's not what I want.

1
do you remember to this problem? Are you able to boost a term during indexing time?Lóri Nóda
@LóriNóda no, sorry, I remember neither the problem nor solution now )kikulikov

1 Answers

1
votes

In Apache Lucene, you can configure boosting in three different places: Document, Field and Query. Since you don't want to boost at the query level, then I think boosting during Field level might come in handy in your case. Method setBoost() of Field class.
Keep in mind that if you add the boost to your field, then you need to do that before adding the document to the index.
You need also to think about what to do when you delete a document from the index or your dictionary of words is changed (which I'm pretty sure it will).