lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject [1/3] lucene-solr:master: SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields
Date Mon, 31 Jul 2017 21:06:42 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7_0 6cc860101 -> 7f954b0c8
  refs/heads/branch_7x 19cb1b883 -> 614467a0a
  refs/heads/master b058818a3 -> 6404abd20


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/6404abd2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6404abd2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6404abd2

Branch: refs/heads/master
Commit: 6404abd2009ed19941dfc0471f7abbf2a47a2b34
Parents: b058818
Author: Steve Rowe <sarowe@apache.org>
Authored: Mon Jul 31 17:03:08 2017 -0400
Committer: Steve Rowe <sarowe@apache.org>
Committed: Mon Jul 31 17:03:08 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/6404abd2/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ed4d1e4..3f8f2e3 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -590,6 +590,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/6404abd2/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/6404abd2/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/6404abd2/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());
+    }
+  }
 }


Mime
View raw message