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 2020/05/15 02:05:52 UTC

[GitHub] [lucene-solr] dsmiley commented on a change in pull request #1517: SOLR-13289: Use the final collector's scoreMode

dsmiley commented on a change in pull request #1517:
URL: https://github.com/apache/lucene-solr/pull/1517#discussion_r425521045



##########
File path: solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java
##########
@@ -189,12 +206,95 @@ public void testMinExactHitsWithMaxScoreRequested() throws IOException {
       cmd.setMinExactHits(2);
       cmd.setFlags(SolrIndexSearcher.GET_SCORES);
       cmd.setQuery(new TermQuery(new Term("field1_s", "foo")));
-      searcher.search(new QueryResult(), cmd);
       QueryResult qr = new QueryResult();
       searcher.search(qr, cmd);
       assertMatchesGraterThan(NUM_DOCS, qr);
       assertNotEquals(Float.NaN, qr.getDocList().maxScore());
       return null;
     });
   }
+  
+  public void testMinExactWithFilters() throws Exception {
+    
+    h.getCore().withSearcher(searcher -> {
+      //Sanity Check - No Filter
+      QueryCommand cmd = new QueryCommand();
+      cmd.setMinExactHits(1);
+      cmd.setLen(1);
+      cmd.setFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
+      cmd.setQuery(new TermQuery(new Term("field4_t", "0")));
+      QueryResult qr = new QueryResult();
+      searcher.search(qr, cmd);
+      assertMatchesGraterThan(NUM_DOCS, qr);
+      return null;
+    });
+    
+    
+    h.getCore().withSearcher(searcher -> {
+      QueryCommand cmd = new QueryCommand();
+      cmd.setMinExactHits(1);
+      cmd.setLen(1);
+      cmd.setFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
+      cmd.setQuery(new TermQuery(new Term("field4_t", "0")));
+      FunctionRangeQuery filterQuery = new FunctionRangeQuery(new ValueSourceRangeFilter(new IntFieldSource("field3_i_dvo"), "19", "19", true, true));
+      cmd.setFilterList(filterQuery);
+      filterQuery.setCache(false);
+      filterQuery.setCost(0);
+      assertNull(searcher.getProcessedFilter(null, cmd.getFilterList()).postFilter);
+      QueryResult qr = new QueryResult();
+      searcher.search(qr, cmd);
+      assertMatchesEqual(1, qr);
+      return null;
+    });
+  }
+  
+  public void testMinExactWithPostFilters() throws Exception {
+    h.getCore().withSearcher(searcher -> {
+      //Sanity Check - No Filter
+      QueryCommand cmd = new QueryCommand();
+      cmd.setMinExactHits(1);
+      cmd.setLen(1);
+      cmd.setFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
+      cmd.setQuery(new TermQuery(new Term("field4_t", "0")));
+      QueryResult qr = new QueryResult();
+      searcher.search(qr, cmd);
+      assertMatchesGraterThan(NUM_DOCS, qr);
+      return null;
+    });
+    
+    
+    h.getCore().withSearcher(searcher -> {
+      QueryCommand cmd = new QueryCommand();
+      cmd.setMinExactHits(1);
+      cmd.setLen(1);
+      cmd.setFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);
+      cmd.setQuery(new TermQuery(new Term("field4_t", "0")));
+      FunctionRangeQuery filterQuery = new FunctionRangeQuery(new ValueSourceRangeFilter(new IntFieldSource("field3_i_dvo"), "19", "19", true, true));

Review comment:
       FYI today FunctionRangeQuery implements PostFilter but it soon won't: https://issues.apache.org/jira/browse/SOLR-14164

##########
File path: solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java
##########
@@ -189,12 +206,95 @@ public void testMinExactHitsWithMaxScoreRequested() throws IOException {
       cmd.setMinExactHits(2);
       cmd.setFlags(SolrIndexSearcher.GET_SCORES);
       cmd.setQuery(new TermQuery(new Term("field1_s", "foo")));
-      searcher.search(new QueryResult(), cmd);
       QueryResult qr = new QueryResult();
       searcher.search(qr, cmd);
       assertMatchesGraterThan(NUM_DOCS, qr);
       assertNotEquals(Float.NaN, qr.getDocList().maxScore());
       return null;
     });
   }
+  
+  public void testMinExactWithFilters() throws Exception {
+    
+    h.getCore().withSearcher(searcher -> {
+      //Sanity Check - No Filter
+      QueryCommand cmd = new QueryCommand();
+      cmd.setMinExactHits(1);
+      cmd.setLen(1);
+      cmd.setFlags(SolrIndexSearcher.NO_CHECK_QCACHE | SolrIndexSearcher.NO_SET_QCACHE);

Review comment:
       Curious; why are you writing tests with this low-level way vs testMinExactHitsDisabledByCollapse which I wrote in a more common higher level style that is more succinct?  Is it only for this NO_CHECK_QCACHE distinction?  Can that be done simply by disabling the cache?  Not a big deal but just want to know your point of view.




----------------------------------------------------------------
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.

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