Reputation: 29
I am looking for a way to tell the lucene searcher to ignore document boosting on certain queries?
In our search results we usually work with a dominant boost-factor calculated by the age of a document while indexing (the index is rebuild nightly).
Now, I am looking for a way offer search-functionality which ignores the age, but found yet no way to override/ignore the document boost.
Best regards,
Alex
Upvotes: 0
Views: 682
Reputation: 41458
http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/search/Similarity.html
From the point 6, I reckon it is impossible to ignore boosts at search time:
norm(t,d) encapsulates a few (indexing time) boost and length factors:
- Document boost - set by calling doc.setBoost() before adding the document to the index.
- Field boost - set by calling field.setBoost() before adding the field to a document.
- lengthNorm(field) - computed when the document is added to the index in accordance with the number of tokens of this field in the document, so that shorter fields contribute more to the score. LengthNorm is computed by the Similarity class in effect at indexing.
When a document is added to the index, all the above factors are multiplied. If the document has multiple fields with the same name, all their boosts are multiplied together:
(...)
Last, note that search time is too late to modify this norm part of scoring, e.g. by using a different Similarity for search.
Upvotes: 1
Reputation: 116178
Instead of storing your calculated-score as boost, you can store it in a new field, and by implementing CustomScoreQuery + CustomScoreProvider you can control which value(default score or your calculated-one in the field) to return
Upvotes: 0
Reputation: 1757
Are you looking for something the QueryParser would understand? Because that is simply not possible.
You're adding the boost somewhere in your code, it is not done by Lucene by default. You'll have to remove this additional piece of code, or make it optional in order to ignore the boost.
Upvotes: 1