[
https://issues.apache.org/jira/browse/LUCENE-6590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15324102#comment-15324102
]
Adrien Grand commented on LUCENE-6590:
--------------------------------------
The code was reorganized a bit, but it should work the same way as before. In
short, one of the idf factors should be counter balanced by the query norm.
Here is what happens in sequence for a term query with a boost of 1 (default):
- upon initialization, IDFStats calls normalize(1,1), which cause queryWeight
to be equal to the idf
- then IndexSearcher calls getValueForNormalization, which return
queryWeight*queryWeight=idf^2
- then IndexSearcher calls
norm=ClassicSimilarity.queryNorm(valueForNormalization) which is
1/sqrt(valueForNormalization) = 1/idf
- then IndexSearcher calls normalize(norm, 1), which gives value = norm * 1 *
idf * idf = 1/idf * 1 * idf * idf = idf
Maybe your code forgot to normalize based on the value of
getValueForNormalization somehow?
> Explore different ways to apply boosts
> --------------------------------------
>
> Key: LUCENE-6590
> URL: https://issues.apache.org/jira/browse/LUCENE-6590
> Project: Lucene - Core
> Issue Type: Wish
> Reporter: Adrien Grand
> Priority: Minor
> Fix For: 5.4
>
> Attachments: LUCENE-6590.patch, LUCENE-6590.patch, LUCENE-6590.patch,
> LUCENE-6590.patch, LUCENE-6590.patch, LUCENE-6590.patch, LUCENE-6590.patch
>
>
> Follow-up from LUCENE-6570: the fact that all queries are mutable in order to
> allow for applying a boost raises issues since it makes queries bad cache
> keys since their hashcode can change anytime. We could just document that
> queries should never be modified after they have gone through IndexSearcher
> but it would be even better if the API made queries impossible to mutate at
> all.
> I think there are two main options:
> - either replace "void setBoost(boost)" with something like "Query
> withBoost(boost)" which would return a clone that has a different boost
> - or move boost handling outside of Query, for instance we could have a
> (immutable) query impl that would be dedicated to applying boosts, that
> queries that need to change boosts at rewrite time (such as BooleanQuery)
> would use as a wrapper.
> The latter idea is from Robert and I like it a lot given how often I either
> introduced or found a bug which was due to the boost parameter being ignored.
> Maybe there are other options, but I think this is worth exploring.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]