You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2017/07/31 22:22:27 UTC
[1/3] lucene-solr:branch_7_0: SOLR-10033: Provide a clear exception
when attempting to facet with facet.mincount=0 over points fields
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7_0 7f954b0c8 -> 4d8c25da8
refs/heads/branch_7x 614467a0a -> 9b5a94621
refs/heads/master 6404abd20 -> 3a405971b
SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over 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/4d8c25da
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4d8c25da
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4d8c25da
Branch: refs/heads/branch_7_0
Commit: 4d8c25da81461d91ad970cf9c14e6f99d5761340
Parents: 7f954b0
Author: Steve Rowe <sa...@apache.org>
Authored: Mon Jul 31 18:21:49 2017 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Mon Jul 31 18:21:49 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../org/apache/solr/request/NumericFacets.java | 15 ++++++++++-
.../org/apache/solr/request/TestFaceting.java | 28 ++++++++++++++++++--
3 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d8c25da/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c139a6c..4280135 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -488,6 +488,9 @@ Other Changes
* SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields.
(hossman, Steve Rowe)
+
+* SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over points fields.
+ (Steve Rowe)
================== 6.7.0 ==================
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d8c25da/solr/core/src/java/org/apache/solr/request/NumericFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/request/NumericFacets.java b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
index fd17f1f..f9f38b3 100644
--- a/solr/core/src/java/org/apache/solr/request/NumericFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
@@ -43,6 +43,7 @@ import org.apache.lucene.util.CharsRefBuilder;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.StringHelper;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.FieldType;
@@ -178,6 +179,11 @@ final class NumericFacets {
if (numericType == null) {
throw new IllegalStateException();
}
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
zeros = zeros && !ft.isPointField() && sf.indexed(); // We don't return zeros when using PointFields or when index=false
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
@@ -407,11 +413,18 @@ final class NumericFacets {
private static NamedList<Integer> getCountsMultiValued(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort) throws IOException {
// If facet.mincount=0 with PointFields the only option is to get the values from DocValues
- // not currently supported. See SOLR-10033
+ // not currently supported. See SOLR-11174
+ boolean zeros = mincount <= 0;
mincount = Math.max(mincount, 1);
final SchemaField sf = searcher.getSchema().getField(fieldName);
final FieldType ft = sf.getType();
assert sf.multiValued();
+
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
// 1. accumulate
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4d8c25da/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 9559b4c..1d99127 100644
--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java
+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java
@@ -27,6 +27,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.uninverting.DocTermOrds;
@@ -335,7 +336,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
@Test
public void testFacetSortWithMinCount0() {
- assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-10033) or single valued DV",
+ assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-11174) or single valued DV",
Boolean.getBoolean(NUMERIC_POINTS_SYSPROP) || Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP));
assertU(adoc("id", "1", "f_td", "-420.126"));
@@ -356,8 +357,31 @@ 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";
+ final SolrQueryRequest req = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, field,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ Exception e = expectThrows(SolrException.class, () -> h.query(req));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + field + " which is Points-based"));
+
+ String mvField = "f_" + new String[]{"is","ls","fs","ds"}[random().nextInt(4)] + "_p";
+ final SolrQueryRequest req2 = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, mvField,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ e = expectThrows(SolrException.class, () -> h.query(req2));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + mvField + " which is Points-based"));
+ }
+
- public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
+ public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
clearIndex();
String fname = "trait_ss";
assertU(adoc("id", "42",
[3/3] lucene-solr:master: SOLR-10033: Provide a clear exception when
attempting to facet with facet.mincount=0 over points fields
Posted by sa...@apache.org.
SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over 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/3a405971
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3a405971
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3a405971
Branch: refs/heads/master
Commit: 3a405971b9e06e2004e0d66ae1b82f530de969f2
Parents: 6404abd
Author: Steve Rowe <sa...@apache.org>
Authored: Mon Jul 31 18:21:49 2017 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Mon Jul 31 18:22:15 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../org/apache/solr/request/NumericFacets.java | 15 ++++++++++-
.../org/apache/solr/request/TestFaceting.java | 28 ++++++++++++++++++--
3 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a405971/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3f8f2e3..01b04aa 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -592,6 +592,9 @@ Other Changes
* SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields.
(hossman, Steve Rowe)
+
+* SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over points fields.
+ (Steve Rowe)
================== 6.7.0 ==================
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a405971/solr/core/src/java/org/apache/solr/request/NumericFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/request/NumericFacets.java b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
index fd17f1f..f9f38b3 100644
--- a/solr/core/src/java/org/apache/solr/request/NumericFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
@@ -43,6 +43,7 @@ import org.apache.lucene.util.CharsRefBuilder;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.StringHelper;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.FieldType;
@@ -178,6 +179,11 @@ final class NumericFacets {
if (numericType == null) {
throw new IllegalStateException();
}
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
zeros = zeros && !ft.isPointField() && sf.indexed(); // We don't return zeros when using PointFields or when index=false
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
@@ -407,11 +413,18 @@ final class NumericFacets {
private static NamedList<Integer> getCountsMultiValued(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort) throws IOException {
// If facet.mincount=0 with PointFields the only option is to get the values from DocValues
- // not currently supported. See SOLR-10033
+ // not currently supported. See SOLR-11174
+ boolean zeros = mincount <= 0;
mincount = Math.max(mincount, 1);
final SchemaField sf = searcher.getSchema().getField(fieldName);
final FieldType ft = sf.getType();
assert sf.multiValued();
+
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
// 1. accumulate
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3a405971/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 9559b4c..1d99127 100644
--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java
+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java
@@ -27,6 +27,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.uninverting.DocTermOrds;
@@ -335,7 +336,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
@Test
public void testFacetSortWithMinCount0() {
- assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-10033) or single valued DV",
+ assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-11174) or single valued DV",
Boolean.getBoolean(NUMERIC_POINTS_SYSPROP) || Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP));
assertU(adoc("id", "1", "f_td", "-420.126"));
@@ -356,8 +357,31 @@ 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";
+ final SolrQueryRequest req = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, field,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ Exception e = expectThrows(SolrException.class, () -> h.query(req));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + field + " which is Points-based"));
+
+ String mvField = "f_" + new String[]{"is","ls","fs","ds"}[random().nextInt(4)] + "_p";
+ final SolrQueryRequest req2 = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, mvField,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ e = expectThrows(SolrException.class, () -> h.query(req2));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + mvField + " which is Points-based"));
+ }
+
- public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
+ public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
clearIndex();
String fname = "trait_ss";
assertU(adoc("id", "42",
[2/3] lucene-solr:branch_7x: SOLR-10033: Provide a clear exception
when attempting to facet with facet.mincount=0 over points fields
Posted by sa...@apache.org.
SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over 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/9b5a9462
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9b5a9462
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9b5a9462
Branch: refs/heads/branch_7x
Commit: 9b5a94621b7866e135f9400c437b73c7c501485b
Parents: 614467a
Author: Steve Rowe <sa...@apache.org>
Authored: Mon Jul 31 18:21:49 2017 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Mon Jul 31 18:22:07 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../org/apache/solr/request/NumericFacets.java | 15 ++++++++++-
.../org/apache/solr/request/TestFaceting.java | 28 ++++++++++++++++++--
3 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9b5a9462/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4af8e62..a42bdef 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -575,6 +575,9 @@ Other Changes
* SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields.
(hossman, Steve Rowe)
+
+* SOLR-10033: Provide a clear exception when attempting to facet with facet.mincount=0 over points fields.
+ (Steve Rowe)
================== 6.7.0 ==================
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9b5a9462/solr/core/src/java/org/apache/solr/request/NumericFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/request/NumericFacets.java b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
index fd17f1f..f9f38b3 100644
--- a/solr/core/src/java/org/apache/solr/request/NumericFacets.java
+++ b/solr/core/src/java/org/apache/solr/request/NumericFacets.java
@@ -43,6 +43,7 @@ import org.apache.lucene.util.CharsRefBuilder;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.PriorityQueue;
import org.apache.lucene.util.StringHelper;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.FieldType;
@@ -178,6 +179,11 @@ final class NumericFacets {
if (numericType == null) {
throw new IllegalStateException();
}
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
zeros = zeros && !ft.isPointField() && sf.indexed(); // We don't return zeros when using PointFields or when index=false
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
@@ -407,11 +413,18 @@ final class NumericFacets {
private static NamedList<Integer> getCountsMultiValued(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort) throws IOException {
// If facet.mincount=0 with PointFields the only option is to get the values from DocValues
- // not currently supported. See SOLR-10033
+ // not currently supported. See SOLR-11174
+ boolean zeros = mincount <= 0;
mincount = Math.max(mincount, 1);
final SchemaField sf = searcher.getSchema().getField(fieldName);
final FieldType ft = sf.getType();
assert sf.multiValued();
+
+ if (zeros && ft.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is Points-based");
+ }
+
final List<LeafReaderContext> leaves = searcher.getIndexReader().leaves();
// 1. accumulate
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9b5a9462/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 9559b4c..1d99127 100644
--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java
+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java
@@ -27,6 +27,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.uninverting.DocTermOrds;
@@ -335,7 +336,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
@Test
public void testFacetSortWithMinCount0() {
- assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-10033) or single valued DV",
+ assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-11174) or single valued DV",
Boolean.getBoolean(NUMERIC_POINTS_SYSPROP) || Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP));
assertU(adoc("id", "1", "f_td", "-420.126"));
@@ -356,8 +357,31 @@ 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";
+ final SolrQueryRequest req = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, field,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ Exception e = expectThrows(SolrException.class, () -> h.query(req));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + field + " which is Points-based"));
+
+ String mvField = "f_" + new String[]{"is","ls","fs","ds"}[random().nextInt(4)] + "_p";
+ final SolrQueryRequest req2 = req("q", "id:1.0",
+ FacetParams.FACET, "true",
+ FacetParams.FACET_FIELD, mvField,
+ FacetParams.FACET_MINCOUNT, "0",
+ FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fc);
+ e = expectThrows(SolrException.class, () -> h.query(req2));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
+ assertTrue(e.getMessage().contains("Cannot use facet.mincount=0 on field " + mvField + " which is Points-based"));
+ }
+
- public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
+ public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
clearIndex();
String fname = "trait_ss";
assertU(adoc("id", "42",