mirror of
https://github.com/apache/lucene.git
synced 2025-02-24 11:16:35 +00:00
SOLR-10847: Provide a clear exception when attempting to use the terms component with points fields
This commit is contained in:
parent
b058818a3e
commit
6404abd200
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user