[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719221#comment-16719221
 ] 

Christian Ziech commented on LUCENE-8606:
-

Those two failing tests are now also fixed, but I'm not sure if I did so in the 
proper way. Someone with more insight on what the SpanWeight should return in 
explain() if the simScorer field is null should have a look.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719183#comment-16719183
 ] 

Christian Ziech commented on LUCENE-8606:
-

Attached a new patch that fixes all but 2 test failures:
{noformat}
   [junit4] Tests with failures [seed: 9F8CCC24EB4194B4]:
   [junit4]   - org.apache.lucene.search.TestComplexExplanations.test2
   [junit4]   - 
org.apache.lucene.search.TestComplexExplanationsOfNonMatches.test2
{noformat}
Those two failures are both caused by a NPE in the LeafSimScorer which is 
caused by the SpanWeight trying to explain a result with a "null" scorer.

Also I had to include a kind of controversial change in the patch which removes 
the assertion "assert scoreMode.needsScores()" from the score() method of the 
AssertingScorer. The problem is that the explain method of the BooleanQuery is 
invoking the score() function to fill the value of the Explanation() object and 
if that BooleanQuery is explained in the context of a ConstantScoreQuery, this 
assertion would fire. 
I first tried to compute the value of the Explanation based on the detail 
explanations in the BooleanQuery, but that didn't quite add up due to 
double/float inaccuracies.


> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719068#comment-16719068
 ] 

Christian Ziech commented on LUCENE-8606:
-

Getting the tests you mentioned to work is the easy part. The harder part is 
that explaining a BooleanWeight which was created with "needsScores == false" 
is running into assertions...

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719035#comment-16719035
 ] 

Christian Ziech commented on LUCENE-8606:
-

I'm running them right now - somehow I remembered that there was a jenkins job 
that would auto-verify patches in tickets. But most likely I remembered that 
wrong.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Adrien Grand (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719031#comment-16719031
 ] 

Adrien Grand commented on LUCENE-8606:
--

Thanks [~christianziech], this looks good to me. Have you checked whether tests 
pass? I know some tests check eg. that scores are equal between an explanation 
and its sub explanation unless a certain pattern can be found in the 
explanation string.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719028#comment-16719028
 ] 

Christian Ziech commented on LUCENE-8606:
-

Sure - that definitely makes the patch smaller. I attached  
[^0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch] which 
performs the change only for the ConstantScoreQuery and the 
CachingWrapperWeight. This adds a small amount of code duplication though.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch, 
> 0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Adrien Grand (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719020#comment-16719020
 ] 

Adrien Grand commented on LUCENE-8606:
--

Good catch that we need to improve CachingWrapperWeight as well. I'd rather 
keep only one ConstantScoreWeight constructor and only fix CachingWrapperWeight 
and the anonymous weight in ConstantScoreQuery.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719003#comment-16719003
 ] 

Christian Ziech commented on LUCENE-8606:
-

[~jpountz] sure I could also just overwrite the CachingWrapperWeight of the 
LRUQueryCache and the anonymous inner class of the ConstantScoreQuery ... as 
you prefer.

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
> Attachments: 
> 0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch
>
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Adrien Grand (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16718984#comment-16718984
 ] 

Adrien Grand commented on LUCENE-8606:
--

bq. changing the Constructor signature would be possibly problematic

The API is expert: only users that write custom queries would be affected. Plus 
APIs that we expect to occasionally need to change are usually tagged with 
@lucene.internal or @lucene.experimental to let users know about this. So 
changing the API is not a big deal.

bq. So I'd add another constructor that would pass in the wrapped Weigth. So 
the behavior would be improved if the wrapped weight is passed in, and would 
remain unchanged if that weight is missing. 

Actually I'm not sure that we need to change ConstantScoreWeight at all: 
ConstantScoreQuery is the only place where we create a ConstantScoreWeight that 
pulls scorers from another weight. So it looks like we would be fine by only 
changing the anonymous subclass of ConstantScoreWeight that is created from 
ConstantScoreQuery#createWeight?

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Christian Ziech (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16718830#comment-16718830
 ] 

Christian Ziech commented on LUCENE-8606:
-

Sure I would be happy to supply a change but I think I'd first like to agree on 
an approach. The main challenge is imo that the ConstantScoreWeigth is 
subclassed at a lot of places in an outside of lucene and changing the 
Constructor signature would be possibly problematic.
So I'd add another constructor that would pass in the wrapped Weigth. So the 
behavior would be improved if the wrapped weight is passed in, and would remain 
unchanged if that weight is missing. 
A fix that changes all usages of the ConstantScoreWeigth is possible too but 
that would break compatibility (as I'd replace the Query parameter with a 
Weight parameter instead of just adding an alternative constructor) ...

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (LUCENE-8606) ConstantScoreQuery looses explain details of wrapped query

2018-12-12 Thread Adrien Grand (JIRA)


[ 
https://issues.apache.org/jira/browse/LUCENE-8606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16718827#comment-16718827
 ] 

Adrien Grand commented on LUCENE-8606:
--

Would you like to work on a fix?

> ConstantScoreQuery looses explain details of wrapped query
> --
>
> Key: LUCENE-8606
> URL: https://issues.apache.org/jira/browse/LUCENE-8606
> Project: Lucene - Core
>  Issue Type: Improvement
>Reporter: Christian Ziech
>Priority: Major
>
> Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not 
> adding the details of the wrapped query to the explanation. 
> {code}
> if (exists) {
> return Explanation.match(score, getQuery().toString() + (score == 1f ? "" 
> : "^" + score));
> } else {
> return Explanation.noMatch(getQuery().toString() + " doesn't match id " + 
> doc);
> }
> {code}
> This is kind of inconvenient as it makes it kind of hard to figure out which 
> term finally really matched when one e.g. puts a BooleanQuery into the FILTER 
> clause of another BooleanQuery.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org