You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/07/21 04:51:23 UTC

[GitHub] [lucene] zacharymorn opened a new pull request, #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

zacharymorn opened a new pull request, #1039:
URL: https://github.com/apache/lucene/pull/1039

   ### Description (or a Jira issue link if you have one)
   
   Ensure test coverage for WANDScorer by using a test query


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] zacharymorn commented on pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
zacharymorn commented on PR #1039:
URL: https://github.com/apache/lucene/pull/1039#issuecomment-1279818045

   > I just realized this PR had got off my radar. Feel free to merge, I don't want to delay improvements to testing.
   
   No problem @jpountz and thanks for the approval! Will merge it in a bit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] zacharymorn commented on a diff in pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
zacharymorn commented on code in PR #1039:
URL: https://github.com/apache/lucene/pull/1039#discussion_r940877761


##########
lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java:
##########
@@ -947,4 +988,82 @@ public long cost() {
       };
     }
   }
+
+  private static class WANDScorerQuery extends Query {
+    private final BooleanQuery query;
+
+    private WANDScorerQuery(BooleanQuery query) {

Review Comment:
   Hmm do you mean for current caller pattern like the following:
   
   ```
   Query query =
               new BooleanQuery.Builder()
                   .add(
                       new WANDScorerQuery(
                           new BooleanQuery.Builder()
                               .add(
                                   new BoostQuery(
                                       new ConstantScoreQuery(new TermQuery(new Term("foo", "A"))), 2),
                                   Occur.SHOULD)
                               .add(
                                   new ConstantScoreQuery(new TermQuery(new Term("foo", "B"))),
                                   Occur.SHOULD)
                               .add(
                                   new BoostQuery(
                                       new ConstantScoreQuery(new TermQuery(new Term("foo", "D"))), 4),
                                   Occur.SHOULD)
                               .setMinimumNumberShouldMatch(2)
                               .build()),
                       Occur.MUST)
                   .add(new TermQuery(new Term("foo", "C")), Occur.FILTER)
                   .build();
   ```
   
   we would like to see if we can create the same via the following calling pattern:
   
   ```
   // missing Occur.MUST from the above between boolean queries
   Query = new WANDScorerQuery(
                           new BooleanQuery.Builder()
                               .add(
                                   new BoostQuery(
                                       new ConstantScoreQuery(new TermQuery(new Term("foo", "A"))), 2),
                                   Occur.SHOULD)
                               .add(
                                   new ConstantScoreQuery(new TermQuery(new Term("foo", "B"))),
                                   Occur.SHOULD)
                               .add(
                                   new BoostQuery(
                                       new ConstantScoreQuery(new TermQuery(new Term("foo", "D"))), 4),
                                   Occur.SHOULD)
                               .setMinimumNumberShouldMatch(2)
                               .build(),
   
                           new BooleanQuery.Builder().add(new TermQuery(new Term("foo", "C")), Occur.FILTER).build());
   ```
   
   I feel this constructor API may not be easy to capture the (boolean) relationship between queries, and also allow non boolean queries to be passed in, which may complicate logic inside the class? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] jpountz commented on a diff in pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
jpountz commented on code in PR #1039:
URL: https://github.com/apache/lucene/pull/1039#discussion_r929867414


##########
lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java:
##########
@@ -815,7 +856,7 @@ private void doTestRandomSpecialMaxScore(float maxScore) throws IOException {
         }
         builder.add(query, Occur.SHOULD);
       }
-      Query query = builder.build();
+      Query query = numClauses > 0 ? new WANDScorerQuery(builder.build()) : builder.build();

Review Comment:
   Maybe we could instead handle it in WandScorerQuery by returning the single scorer when there is a single clause?



##########
lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java:
##########
@@ -947,4 +988,82 @@ public long cost() {
       };
     }
   }
+
+  private static class WANDScorerQuery extends Query {
+    private final BooleanQuery query;
+
+    private WANDScorerQuery(BooleanQuery query) {

Review Comment:
   I wonder if it would make the tests easier to read if we took an array of queries here:
   
   ```suggestion
       private WANDScorerQuery(Query... query) {
   ```
   
   while still creating a `BooleanQuery` under the hood to reuse equals/hashcode/etc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] zacharymorn commented on a diff in pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
zacharymorn commented on code in PR #1039:
URL: https://github.com/apache/lucene/pull/1039#discussion_r940876636


##########
lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java:
##########
@@ -815,7 +856,7 @@ private void doTestRandomSpecialMaxScore(float maxScore) throws IOException {
         }
         builder.add(query, Occur.SHOULD);
       }
-      Query query = builder.build();
+      Query query = numClauses > 0 ? new WANDScorerQuery(builder.build()) : builder.build();

Review Comment:
   Thanks for the suggestion! This case is actually trying to handle the scenario when there's 0 clause, upon which `WANDScorer` may throw assertion exception due to the following check: 
   
   ```
   if (minShouldMatch >= scorers.size()) {
       throw new IllegalArgumentException("minShouldMatch should be < the number of scorers");
   }
   ```
   However, upon digging further, I think the current code is still not enough, as `optionalScorers` can still have a size of 0 later on as well if there's no scorer for a clause for certain segment. I've updated it to https://github.com/apache/lucene/pull/1039/commits/511d1b2b2b6ffe8994d839a05830b2f629e0e0e3 to catch that scenario as well.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] zacharymorn commented on pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
zacharymorn commented on PR #1039:
URL: https://github.com/apache/lucene/pull/1039#issuecomment-1191043324

   I guess this will go into `10.0.0`, as `9.3` has already been cut and the PR is test only?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] jpountz commented on a diff in pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
jpountz commented on code in PR #1039:
URL: https://github.com/apache/lucene/pull/1039#discussion_r982215123


##########
lucene/core/src/test/org/apache/lucene/search/TestWANDScorer.java:
##########
@@ -947,4 +988,82 @@ public long cost() {
       };
     }
   }
+
+  private static class WANDScorerQuery extends Query {
+    private final BooleanQuery query;
+
+    private WANDScorerQuery(BooleanQuery query) {

Review Comment:
   I was thinking of something like that indeed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] zacharymorn merged pull request #1039: LUCENE-10635: Ensure test coverage for WANDScorer by using a test query

Posted by GitBox <gi...@apache.org>.
zacharymorn merged PR #1039:
URL: https://github.com/apache/lucene/pull/1039


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org