From c23cecc557b340596832c354df54a0ecf365db9e Mon Sep 17 00:00:00 2001 From: Chris Hostetter Date: Tue, 18 Jul 2017 15:47:31 -0700 Subject: [PATCH] SOLR-11114: Randomize PointFields in schema-customfield.xml and TestOverriddenPrefixQueryForCustomFieldType --- solr/CHANGES.txt | 1 + .../collection1/conf/schema-customfield.xml | 4 +-- ...tPointPrefixActsAsRangeQueryFieldType.java | 34 +++++++++++++++++++ ...rieIntPrefixActsAsRangeQueryFieldType.java | 2 ++ ...erriddenPrefixQueryForCustomFieldType.java | 4 +++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 solr/core/src/test/org/apache/solr/schema/IntPointPrefixActsAsRangeQueryFieldType.java 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 @@ - + - + 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"); }