Skip to content

Apache Lucene open-source search software

SOLR-11114: Randomize PointFields in schema-customfield.xml and TestOverriddenPrefixQueryForCustomFieldType

Chris Hostetterc23cecc557b3
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index cd6e1c5c7af..77011765efb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -517,6 +517,7 @@ Other Changes
- SOLR-11118: Randomize PointFields in schema-HighlighterMaxOffsetTest.xml, schema-luceneMatchVersion.xml,
schema-minimal-atomic-stress.xml, and all affected tests (Steve Rowe)
- SOLR-11113: Randomize PointFields in analysis-err-schema.xml, schema-hash.xml, and all affected tests (hossman)
+ - SOLR-11114: Randomize PointFields in schema-customfield.xml and TestOverriddenPrefixQueryForCustomFieldType (hossman)
* SOLR-6807: Changed requestDispatcher's handleSelect to default to false, thus ignoring "qt".
Simplified configs to not refer to handleSelect or "qt". Switch all tests that assumed true to assume false
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-customfield.xml b/solr/core/src/test-files/solr/collection1/conf/schema-customfield.xml
index cfb147a878f..44cea6351b7 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-customfield.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-customfield.xml
@@ -39,12 +39,12 @@
</analyzer>
</fieldType>
- <fieldType name="customtrieintfield" class="org.apache.solr.schema.TrieIntPrefixActsAsRangeQueryFieldType"/>
+ <fieldType name="customintfield" class="${solr.tests.CustomIntFieldType}" docValues="${solr.tests.numeric.dv}" />
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="intfield" type="int" indexed="true" stored="true"/>
<field name="swap_foo_bar_in_prefix_query" type="customfield" indexed="true" stored="true" multiValued="true"/>
- <field name="int_prefix_as_range" type="customtrieintfield" indexed="true" stored="true"/>
+ <field name="int_prefix_as_range" type="customintfield" indexed="true" stored="true"/>
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
diff --git a/solr/core/src/test/org/apache/solr/schema/IntPointPrefixActsAsRangeQueryFieldType.java b/solr/core/src/test/org/apache/solr/schema/IntPointPrefixActsAsRangeQueryFieldType.java
new file mode 100644
index 00000000000..e9acdee8186
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/schema/IntPointPrefixActsAsRangeQueryFieldType.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.schema;
+
+import org.apache.lucene.search.Query;
+import org.apache.solr.search.QParser;
+
+/**
+ * Custom field type that overrides the prefix query behavior to map "X*" to [X TO Integer.MAX_VALUE].
+ * * This is used for testing overridden prefix query for custom fields in TestOverriddenPrefixQueryForCustomFieldType
+ *
+ * @see TrieIntPrefixActsAsRangeQueryFieldType
+ */
+public class IntPointPrefixActsAsRangeQueryFieldType extends IntPointField {
+
+ public Query getPrefixQuery(QParser parser, SchemaField sf, String termStr) {
+ return getRangeQuery(parser, sf, termStr, Integer.MAX_VALUE + "", true, false);
+ }
+
+}
diff --git a/solr/core/src/test/org/apache/solr/schema/TrieIntPrefixActsAsRangeQueryFieldType.java b/solr/core/src/test/org/apache/solr/schema/TrieIntPrefixActsAsRangeQueryFieldType.java
index 4b799755212..8e311213860 100644
--- a/solr/core/src/test/org/apache/solr/schema/TrieIntPrefixActsAsRangeQueryFieldType.java
+++ b/solr/core/src/test/org/apache/solr/schema/TrieIntPrefixActsAsRangeQueryFieldType.java
@@ -22,6 +22,8 @@ import org.apache.solr.search.QParser;
/**
* Custom field type that overrides the prefix query behavior to map "X*" to [X TO Integer.MAX_VALUE].
* * This is used for testing overridden prefix query for custom fields in TestOverriddenPrefixQueryForCustomFieldType
+ *
+ * @see IntPointPrefixActsAsRangeQueryFieldType
*/
public class TrieIntPrefixActsAsRangeQueryFieldType extends TrieIntField {
diff --git a/solr/core/src/test/org/apache/solr/search/TestOverriddenPrefixQueryForCustomFieldType.java b/solr/core/src/test/org/apache/solr/search/TestOverriddenPrefixQueryForCustomFieldType.java
index 15012ccfa1b..73fa9288d0b 100644
--- a/solr/core/src/test/org/apache/solr/search/TestOverriddenPrefixQueryForCustomFieldType.java
+++ b/solr/core/src/test/org/apache/solr/search/TestOverriddenPrefixQueryForCustomFieldType.java
@@ -36,6 +36,10 @@ public class TestOverriddenPrefixQueryForCustomFieldType extends SolrTestCaseJ4
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("solr.tests.CustomIntFieldType",
+ (Boolean.getBoolean(NUMERIC_POINTS_SYSPROP)
+ ? "solr.IntPointPrefixActsAsRangeQueryFieldType"
+ : "solr.TrieIntPrefixActsAsRangeQueryFieldType"));
initCore("solrconfig-basic.xml", "schema-customfield.xml");
}