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

This commit is contained in:
Chris Hostetter 2017-07-18 15:47:31 -07:00
parent 63acac6379
commit c23cecc557
5 changed files with 43 additions and 2 deletions

View File

@ -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

View File

@ -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"/>

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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");
}