[ https://issues.apache.org/jira/browse/LUCENE-7276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15327946#comment-15327946 ]
Ferenczi Jim edited comment on LUCENE-7276 at 6/13/16 7:02 PM: --------------------------------------------------------------- ??Somehow the test is angry that the rewritten query scores differently from the original ... so somehow the fact that we no longer rewrite to an empty BQ is changing something ... I'll dig.?? I tried to find a reason and I think I found something interesting. The change is related to the normalization factor and the fact that those queries are boosted. When you use a boolean query with no clause the normalization factor is 0, when the matchnodocs query is used the normalization factor is 1 (BooleanWeight.getValueForNormalization and ConstantScoreWeight.getValueForNormalization). This part of the query is supposed to return no documents so it should be ok to ignore it when the query norm is computed. Though for the distributed case where results are merged from different shards there is no guarantee that the rewrite will be the same among the shards. I think we can get rid of the matchnodocsquery vs empty boolean query difference if we change the return value of BooleanWeight.getValueForNormalization to be 1 (instead of 0) when there is no clause. https://issues.apache.org/jira/browse/LUCENE-7337 was (Author: jim.ferenczi): ?? Somehow the test is angry that the rewritten query scores differently from the original ... so somehow the fact that we no longer rewrite to an empty BQ is changing something ... I'll dig. ?? I tried to find a reason and I think I found something interesting. The change is related to the normalization factor and the fact that those queries are boosted. When you use a boolean query with no clause the normalization factor is 0, when the matchnodocs query is used the normalization factor is 1 (BooleanWeight.getValueForNormalization and ConstantScoreWeight.getValueForNormalization). This part of the query is supposed to return no documents so it should be ok to ignore it when the query norm is computed. Though for the distributed case where results are merged from different shards there is no guarantee that the rewrite will be the same among the shards. I think we can get rid of the matchnodocsquery vs empty boolean query difference if we change the return value of BooleanWeight.getValueForNormalization to be 1 (instead of 0) when there is no clause. https://issues.apache.org/jira/browse/LUCENE-7337 > Add an optional reason to the MatchNoDocsQuery > ---------------------------------------------- > > Key: LUCENE-7276 > URL: https://issues.apache.org/jira/browse/LUCENE-7276 > Project: Lucene - Core > Issue Type: Improvement > Components: core/search > Reporter: Ferenczi Jim > Priority: Minor > Labels: patch > Attachments: LUCENE-7276.patch, LUCENE-7276.patch, LUCENE-7276.patch, > LUCENE-7276.patch, LUCENE-7276.patch > > > It's sometimes difficult to debug a query that results in a MatchNoDocsQuery. > The MatchNoDocsQuery is always rewritten in an empty boolean query. > This patch adds an optional reason and implements a weight in order to keep > track of the reason why the query did not match any document. The reason is > printed on toString and when an explanation for noMatch is asked. > For instance the query: > new MatchNoDocsQuery("Field not found").toString() > => 'MatchNoDocsQuery["field 'title' not found"]' -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org