mirror of https://github.com/apache/lucene.git
SOLR-10919: ord & rord functions give confusing errors with PointFields
This commit is contained in:
parent
5adceeb652
commit
88614dd15f
|
@ -588,6 +588,8 @@ Other Changes
|
|||
|
||||
* SOLR-11036: Separately report disk space metrics for solr.data.home and core root directory. (ab)
|
||||
|
||||
* SOLR-10919: ord & rord functions give confusing errors with PointFields. (hossman, Steve Rowe)
|
||||
|
||||
================== 6.7.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
|||
import org.apache.lucene.search.SortedSetSelector;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueInt;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.search.Insanity;
|
||||
|
@ -77,6 +78,10 @@ public class OrdFieldSource extends ValueSource {
|
|||
if (o instanceof SolrIndexSearcher) {
|
||||
SolrIndexSearcher is = (SolrIndexSearcher) o;
|
||||
SchemaField sf = is.getSchema().getFieldOrNull(field);
|
||||
if (sf != null && sf.getType().isPointField()) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
||||
"ord() is not supported over Points based field " + field);
|
||||
}
|
||||
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumberType() != null) {
|
||||
// it's a single-valued numeric field: we must currently create insanity :(
|
||||
List<LeafReaderContext> leaves = is.getIndexReader().leaves();
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.lucene.queries.function.FunctionValues;
|
|||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.SortedSetSelector;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.search.Insanity;
|
||||
|
@ -77,6 +78,10 @@ public class ReverseOrdFieldSource extends ValueSource {
|
|||
if (o instanceof SolrIndexSearcher) {
|
||||
SolrIndexSearcher is = (SolrIndexSearcher) o;
|
||||
SchemaField sf = is.getSchema().getFieldOrNull(field);
|
||||
if (sf != null && sf.getType().isPointField()) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
||||
"rord() is not supported over Points based field " + field);
|
||||
}
|
||||
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumberType() != null) {
|
||||
// it's a single-valued numeric field: we must currently create insanity :(
|
||||
List<LeafReaderContext> leaves = is.getIndexReader().leaves();
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Random;
|
|||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.search.similarities.TFIDFSimilarity;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -302,6 +303,24 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
|
|||
makeExternalFile(extField, "91=543210\n92=-8\n93=250\n=67");
|
||||
singleTest(extField,"\0",991,543210,992,-8,993,250);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrdAndRordOverPointsField() throws Exception {
|
||||
assumeTrue("Skipping test when points=false", Boolean.getBoolean(NUMERIC_POINTS_SYSPROP));
|
||||
clearIndex();
|
||||
|
||||
String field = "a_" + new String[] {"i","l","d","f"}[random().nextInt(4)];
|
||||
assertU(adoc("id", "1", field, "1"));
|
||||
assertU(commit());
|
||||
|
||||
Exception e = expectThrows(SolrException.class, () -> h.query(req("q", "{!func}ord(" + field + ")", "fq", "id:1")));
|
||||
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
|
||||
assertTrue(e.getMessage().contains("ord() is not supported over Points based field " + field));
|
||||
|
||||
e = expectThrows(SolrException.class, () -> h.query(req("q", "{!func}rord(" + field + ")", "fq", "id:1")));
|
||||
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ((SolrException)e).code());
|
||||
assertTrue(e.getMessage().contains("rord() is not supported over Points based field " + field));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeneral() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue