s1monw commented on a change in pull request #581: LUCENE-3041: QueryVisitor
URL: https://github.com/apache/lucene-solr/pull/581#discussion_r260740578
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
 ##########
 @@ -764,15 +763,31 @@ public void testExtractTerms() throws IOException {
     bqBuilder.add(new TermQuery(b), Occur.MUST);
     bqBuilder.add(new TermQuery(c), Occur.FILTER);
     bqBuilder.add(new TermQuery(d), Occur.MUST_NOT);
-    IndexSearcher searcher = new IndexSearcher(new MultiReader());
     BooleanQuery bq = bqBuilder.build();
 
-    Set<Term> scoringTerms = new HashSet<>();
-    searcher.createWeight(searcher.rewrite(bq), ScoreMode.COMPLETE, 
1).extractTerms(scoringTerms);
-    assertEquals(new HashSet<>(Arrays.asList(a, b)), scoringTerms);
+    bq.visit(new QueryVisitor() {
+
+      Term expected;
 
-    Set<Term> matchingTerms = new HashSet<>();
-    searcher.createWeight(searcher.rewrite(bq), ScoreMode.COMPLETE_NO_SCORES, 
1).extractTerms(matchingTerms);
-    assertEquals(new HashSet<>(Arrays.asList(a, b, c)), matchingTerms);
+      @Override
+      public QueryVisitor getSubVisitor(Occur occur, Query parent) {
+        switch (occur) {
+          case SHOULD:
+            expected = a; break;
 
 Review comment:
   can you move the break on an extra line please

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to