mirror of https://github.com/apache/lucene.git
SOLR-14291: fix regexps to handle dotted fields in Old Analytics params.
This commit is contained in:
parent
9340e56551
commit
b24b028402
|
@ -122,6 +122,8 @@ Bug Fixes
|
|||
This is a fix for incomplete optimization made by SOLR-11880 in Solr 7.4 which fixed distributed updates but not
|
||||
distributed search. (shalin)
|
||||
|
||||
* SOLR-14291: Handle dotted fields in legacy Analytics Component (Anatolii Siuniaev via Mikhail Khludnev)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
* SOLR-14197: SolrResourceLoader: marked many methods as deprecated, and in some cases rerouted exiting logic to avoid
|
||||
|
|
|
@ -48,14 +48,14 @@ public interface OldAnalyticsParams {
|
|||
public Map<String,OldQueryFacet> queryFacets = new HashMap<>();
|
||||
}
|
||||
|
||||
public static final String FIELD_FACET = "ff|fieldfacet";
|
||||
public static final String VALUE_FACET = "vf|valuefacet";
|
||||
public static final String LIMIT = "l|limit";
|
||||
public static final String OFFSET = "off|offset";
|
||||
public static final String SHOW_MISSING = "sm|showmissing";
|
||||
public static final String SORT_EXPRESSION ="se|sortexpr|sortexpression";
|
||||
public static final String OLAP_SORT_EXPRESSION ="ss|sortstat|sortstatistic";
|
||||
public static final String SORT_DIRECTION ="sd|sortdirection";
|
||||
public static final String FIELD_FACET = "(?:ff|fieldfacet)";
|
||||
public static final String VALUE_FACET = "(?:vf|valuefacet)";
|
||||
public static final String LIMIT = "(?:l|limit)";
|
||||
public static final String OFFSET = "(?:off|offset)";
|
||||
public static final String SHOW_MISSING = "(?:sm|showmissing)";
|
||||
public static final String SORT_EXPRESSION ="(?:se|sortexpr|sortexpression)";
|
||||
public static final String OLAP_SORT_EXPRESSION ="(?:ss|sortstat|sortstatistic)";
|
||||
public static final String SORT_DIRECTION ="(?:sd|sortdirection)";
|
||||
|
||||
public static class OldFieldFacet {
|
||||
public String field;
|
||||
|
@ -114,13 +114,13 @@ public interface OldAnalyticsParams {
|
|||
}
|
||||
}
|
||||
|
||||
public static final String RANGE_FACET = "rf|rangefacet";
|
||||
public static final String START = "st|start";
|
||||
public static final String END = "e|end";
|
||||
public static final String GAP = "g|gap";
|
||||
public static final String HARDEND = "he|hardend";
|
||||
public static final String INCLUDE_BOUNDARY = "ib|includebound";
|
||||
public static final String OTHER_RANGE = "or|otherrange";
|
||||
public static final String RANGE_FACET = "(?:rf|rangefacet)";
|
||||
public static final String START = "(?:st|start)";
|
||||
public static final String END = "(?:e|end)";
|
||||
public static final String GAP = "(?:g|gap)";
|
||||
public static final String HARDEND = "(?:he|hardend)";
|
||||
public static final String INCLUDE_BOUNDARY = "(?:ib|includebound)";
|
||||
public static final String OTHER_RANGE = "(?:or|otherrange)";
|
||||
|
||||
public static class OldRangeFacet {
|
||||
public String field;
|
||||
|
@ -170,8 +170,8 @@ public interface OldAnalyticsParams {
|
|||
public String[] queries;
|
||||
}
|
||||
|
||||
public static final String QUERY_FACET = "qf|queryfacet";
|
||||
public static final String QUERY = "q|query";
|
||||
public static final String QUERY_FACET = "(?:qf|queryfacet)";
|
||||
public static final String QUERY = "(?:q|query)";
|
||||
|
||||
//Defaults
|
||||
public static final boolean DEFAULT_ABBREVIATE_PREFIX = true;
|
||||
|
|
|
@ -38,9 +38,9 @@ public class OldAnalyticsRequestConverter implements OldAnalyticsParams {
|
|||
private static final Pattern oldFieldFacetPattern =
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+FIELD_FACET+")$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern oldFieldFacetParamPattern =
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+FIELD_FACET+")\\.([^\\.]+)\\.("+FieldFacetParamParser.regexParamList+")$", Pattern.CASE_INSENSITIVE);
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+FIELD_FACET+")\\.(.*(?=\\.))\\.("+FieldFacetParamParser.regexParamList+")$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern oldRangeFacetParamPattern =
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+RANGE_FACET+")\\.([^\\.]+)\\.("+RangeFacetParamParser.regexParamList+")$", Pattern.CASE_INSENSITIVE);
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+RANGE_FACET+")\\.(.*(?=\\.))\\.("+RangeFacetParamParser.regexParamList+")$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern oldQueryFacetParamPattern =
|
||||
Pattern.compile("^(?:"+OLD_PREFIX+")\\.([^\\.]+)\\.(?:"+QUERY_FACET+")\\.([^\\.]+)\\.("+QUERY+")$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
o.df1.s.mean=mean(long.dotfield)
|
||||
o.df1.ff=long.dotfield
|
||||
o.df1.ff.long.dotfield.ss=mean
|
||||
o.df1.ff.long.dotfield.sd=asc
|
||||
|
||||
o.df2.s.count=count(long.dotfield)
|
||||
o.df2.rf=long.dotfield
|
||||
o.df2.rf.long.dotfield.st=5
|
||||
o.df2.rf.long.dotfield.end=30
|
||||
o.df2.rf.long.dotfield.hardend=True
|
||||
o.df2.rf.long.dotfield.g=5
|
||||
o.df2.rf.long.dotfield.ib=lower
|
||||
o.df2.rf.long.dotfield.or=all
|
||||
|
||||
|
||||
|
|
@ -62,6 +62,8 @@
|
|||
<fieldType name="double_pnt" class="solr.DoublePointField" docValues="true" />
|
||||
<fieldType name="date_pnt" class="solr.DatePointField" docValues="true" />
|
||||
|
||||
<field name="long.dotfield" type="long_pnt"/>
|
||||
|
||||
<fieldType name="boolean" class="solr.BoolField" docValues="true"/>
|
||||
<fieldType name="string" class="solr.StrField" docValues="true"/>
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.analytics.util;
|
||||
|
||||
import org.apache.solr.analytics.legacy.facet.LegacyAbstractAnalyticsFacetTest;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsExpressionSortRequest;
|
||||
import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRequest;
|
||||
import static org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsValueFacetRequest;
|
||||
|
||||
import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsFacetRequest;
|
||||
import org.apache.solr.analytics.AnalyticsRequestParser.AnalyticsRangeFacetRequest;
|
||||
|
||||
public class OldAnalyticsRequestConverterUnitTest extends LegacyAbstractAnalyticsFacetTest {
|
||||
String fileName = "facetWithDottedFields.txt";
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig-analytics.xml", "schema-analytics.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFieldFacetWithDottedField() throws Exception {
|
||||
SolrParams params = request(fileToStringArr(OldAnalyticsRequestConverterUnitTest.class, fileName)).getParams();
|
||||
AnalyticsRequest request = OldAnalyticsRequestConverter.convert(params);
|
||||
final AnalyticsValueFacetRequest analyticsValueFacetRequest = (AnalyticsValueFacetRequest) request.groupings.get("df1").facets.get("long.dotfield");
|
||||
assertNotNull("Sort param should be parsed for dotted field", analyticsValueFacetRequest.sort);
|
||||
final AnalyticsExpressionSortRequest analyticsExpressionSortRequest = (AnalyticsExpressionSortRequest) analyticsValueFacetRequest.sort.criteria.get(0);
|
||||
assertEquals("Sort param expression should be parsed for dotted field",
|
||||
"mean", analyticsExpressionSortRequest.expression);
|
||||
assertEquals("Sort param direction should be parsed for dotted field",
|
||||
"asc", analyticsExpressionSortRequest.direction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertRangeFacetWithDottedField() throws Exception {
|
||||
SolrParams params = request(fileToStringArr(OldAnalyticsRequestConverterUnitTest.class, fileName)).getParams();
|
||||
AnalyticsRequest request = OldAnalyticsRequestConverter.convert(params);
|
||||
|
||||
final AnalyticsFacetRequest analyticsFacetRequest = request.groupings.get("df2").facets.get("long.dotfield");
|
||||
assertNotNull("Range facet param should be parsed for dotted field", analyticsFacetRequest);
|
||||
assertEquals("30", ((AnalyticsRangeFacetRequest)analyticsFacetRequest).end);
|
||||
assertEquals(true, ((AnalyticsRangeFacetRequest)analyticsFacetRequest).hardend);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue