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 21:06:43 UTC
[2/3] lucene-solr:branch_7x: SOLR-10847: Provide a clear exception
when attempting to use the terms component with points fields
SOLR-10847: Provide a clear exception when attempting to use the terms component 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/614467a0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/614467a0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/614467a0
Branch: refs/heads/branch_7x
Commit: 614467a0a137e18f258d270529ef8df474983f20
Parents: 19cb1b8
Author: Steve Rowe <sa...@apache.org>
Authored: Mon Jul 31 17:03:08 2017 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Mon Jul 31 17:06:31 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../solr/handler/component/TermsComponent.java | 10 +++++++
.../DistributedTermsComponentTest.java | 2 +-
.../handler/component/TermsComponentTest.java | 30 +++++++++++++++++++-
4 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/614467a0/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 98117dc..4af8e62 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -573,6 +573,9 @@ Other Changes
* SOLR-10919: ord & rord functions give confusing errors with PointFields. (hossman, Steve Rowe)
+* SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields.
+ (hossman, Steve Rowe)
+
================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/614467a0/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java b/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
index 80dfa40..3f2786b 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java
@@ -108,6 +108,16 @@ public class TermsComponent extends SearchComponent {
rb.rsp.add("terms", termsResult);
if (fields == null || fields.length==0) return;
+
+ for (String field : fields) {
+ FieldType fieldType = rb.req.getSchema().getFieldTypeNoEx(field);
+ if (null != fieldType) {
+ if (fieldType.isPointField()) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "The terms component does not support Points-based field " + field);
+ }
+ }
+ }
boolean termStats = params.getBool(TermsParams.TERMS_STATS, false);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/614467a0/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
index 6f719d2..53ee906 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
*
* @since solr 1.5
*/
-@SuppressPointFields(bugUrl="https://issues.apache.org/jira/browse/SOLR-10847")
+@SuppressPointFields(bugUrl="https://issues.apache.org/jira/browse/SOLR-11173")
public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase {
@Test
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/614467a0/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
index 2a8b653..ac7cf2a 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.handler.component;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.TermsParams;
import org.apache.solr.request.SolrQueryRequest;
@@ -29,7 +30,7 @@ import java.util.regex.Pattern;
*
**/
// TermsComponent not currently supported for PointFields
-@SolrTestCaseJ4.SuppressPointFields(bugUrl="https://issues.apache.org/jira/browse/SOLR-10847")
+@SolrTestCaseJ4.SuppressPointFields(bugUrl="https://issues.apache.org/jira/browse/SOLR-11173")
public class TermsComponentTest extends SolrTestCaseJ4 {
@BeforeClass
@@ -378,4 +379,31 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
"//lst[@name='standardfilt']/lst[@name='aaa']/long[@name='ttf'][.='1']");
}
+ @Test
+ public void testPointField() throws Exception {
+ assertU(adoc("id", "10000", "foo_pi", "1"));
+ assertU(commit());
+
+ try {
+ final SolrQueryRequest req = req(
+ "qt", "/terms",
+ "terms", "true",
+ "terms.fl", "foo_pi");
+ Exception e = expectThrows(SolrException.class, () -> h.query(req));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException) e).code());
+ assertTrue(e.getMessage().contains("The terms component does not support Points-based field foo_pi"));
+
+ final SolrQueryRequest req2 = req(
+ "qt", "/terms",
+ "terms", "true",
+ "terms.fl", "foo_pi",
+ "terms.list", "1");
+ e = expectThrows(SolrException.class, () -> h.query(req2));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException) e).code());
+ assertTrue(e.getMessage().contains("The terms component does not support Points-based field foo_pi"));
+ } finally {
+ assertU(delI("10000"));
+ assertU(commit());
+ }
+ }
}