lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject [1/2] lucene-solr:branch_7x: SOLR-10033: return warning in response header about raising mincount above 0 with points fields
Date Tue, 01 Aug 2017 23:32:04 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7_0 4fddc0eac -> 832ab790c
  refs/heads/branch_7x 4945a125f -> f306d7ca2


SOLR-10033: return warning in response header about raising mincount above 0 with points fields


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f306d7ca
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f306d7ca
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f306d7ca

Branch: refs/heads/branch_7x
Commit: f306d7ca22da89ab24028dff127c7ca6e91a1b66
Parents: 4945a12
Author: Steve Rowe <sarowe@apache.org>
Authored: Tue Aug 1 19:31:31 2017 -0400
Committer: Steve Rowe <sarowe@apache.org>
Committed: Tue Aug 1 19:31:47 2017 -0400

----------------------------------------------------------------------
 .../org/apache/solr/request/SimpleFacets.java   | 11 +++++++++-
 .../org/apache/solr/request/TestFaceting.java   | 22 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f306d7ca/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
index 085b47e..4a911d2 100644
--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
@@ -497,7 +497,16 @@ public class SimpleFacets {
                       + FacetParams.FACET_EXCLUDETERMS + ") are not supported on numeric
types");
             }
             if (ft.isPointField() && mincount <= 0) { // default is mincount=0.
 See SOLR-10033 & SOLR-11174.
-              LOG.warn("Raising facet.mincount from " + mincount + " to 1, because field
" + field + " is Points-based.");
+              String warningMessage 
+                  = "Raising facet.mincount from " + mincount + " to 1, because field " +
field + " is Points-based.";
+              LOG.warn(warningMessage);
+              List<String> warnings = (List<String>)rb.rsp.getResponseHeader().get("warnings");
+              if (null == warnings) {
+                warnings = new ArrayList<>();
+                rb.rsp.getResponseHeader().add("warnings", warnings);
+              }
+              warnings.add(warningMessage);
+
               mincount = 1;
             }
             counts = NumericFacets.getCounts(searcher, docs, field, offset, limit, mincount,
missing, sort);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f306d7ca/solr/core/src/test/org/apache/solr/request/TestFaceting.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/request/TestFaceting.java b/solr/core/src/test/org/apache/solr/request/TestFaceting.java
index 32cb177..ff7d720 100644
--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java
+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java
@@ -356,8 +356,28 @@ public class TestFaceting extends SolrTestCaseJ4 {
         "//lst[@name='facet_fields']/lst[@name='f_td']/int[3][@name='-1.218']");
   }
 
+  @Test
+  public void testFacetOverPointFieldWithMinCount0() {
+    String field = "f_" + new String[]{"i","l","f","d"}[random().nextInt(4)] + "_p";
+    String expectedWarning = "Raising facet.mincount from 0 to 1, because field " + field
+ " is Points-based.";
+    SolrQueryRequest req = req("q", "id:1.0",
+        FacetParams.FACET, "true",
+        FacetParams.FACET_FIELD, field,
+        FacetParams.FACET_MINCOUNT, "0");
+    assertQ(req
+        , "/response/lst[@name='responseHeader']/arr[@name='warnings']/str[.='" + expectedWarning
+ "']");
+    
+    field = "f_" + new String[]{"is","ls","fs","ds"}[random().nextInt(4)] + "_p";
+    expectedWarning = "Raising facet.mincount from 0 to 1, because field " + field + " is
Points-based.";
+    req = req("q", "id:1.0",
+        FacetParams.FACET, "true",
+        FacetParams.FACET_FIELD, field,
+        FacetParams.FACET_MINCOUNT, "0");
+    assertQ(req
+        , "/response/lst[@name='responseHeader']/arr[@name='warnings']/str[.='" + expectedWarning
+ "']");
+  }
 
-    public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
+  public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
       clearIndex();
       String fname = "trait_ss";
       assertU(adoc("id", "42",


Mime
View raw message