mirror of https://github.com/apache/lucene.git
SOLR-8807: disable the CollapseQParser Plugin when testing spellcheck collations for hit-counts
This commit is contained in:
parent
caf329717e
commit
55e36615eb
|
@ -166,6 +166,9 @@ Bug Fixes
|
|||
* SOLR-10264: Fixes multi-term synonym parsing in ManagedSynonymFilterFactory.
|
||||
(Jörg Rathlev, Steve Rowe, Christine Poerschke)
|
||||
|
||||
* SOLR-8807: fix Spellcheck "collateMaxCollectDocs" parameter to work with queries that have the
|
||||
CollpasingQParserPlugin applied. (James Dyer)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.spelling;
|
||||
import static org.apache.solr.common.params.CommonParams.ID;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -41,8 +43,6 @@ import org.apache.solr.search.SolrIndexSearcher;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.ID;
|
||||
|
||||
public class SpellCheckCollator {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private int maxCollations = 1;
|
||||
|
@ -133,6 +133,19 @@ public class SpellCheckCollator {
|
|||
// Collate testing does not support Grouping (see SOLR-2577)
|
||||
params.remove(GroupParams.GROUP);
|
||||
|
||||
// Collate testing does not support the Collapse QParser (See SOLR-8807)
|
||||
params.remove("expand");
|
||||
String[] filters = params.getParams(CommonParams.FQ);
|
||||
if (filters != null) {
|
||||
List<String> filtersToApply = new ArrayList<>(filters.length);
|
||||
for (String fq : filters) {
|
||||
if (!fq.startsWith("{!collapse")) {
|
||||
filtersToApply.add(fq);
|
||||
}
|
||||
}
|
||||
params.set("fq", filtersToApply.toArray(new String[filtersToApply.size()]));
|
||||
}
|
||||
|
||||
// creating a request here... make sure to close it!
|
||||
ResponseBuilder checkResponse = new ResponseBuilder(
|
||||
new LocalSolrQueryRequest(ultimateResponse.req.getCore(), params),
|
||||
|
|
|
@ -239,75 +239,14 @@ based HashBitset. -->
|
|||
|
||||
<searchComponent name="spellcheck" class="org.apache.solr.handler.component.SpellCheckComponent">
|
||||
<!-- This is slightly different from the field value so we can test dealing with token offset changes -->
|
||||
<str name="queryAnalyzerFieldType">lowerpunctfilt</str>
|
||||
<str name="queryAnalyzerFieldType">a_s</str>
|
||||
|
||||
<lst name="spellchecker">
|
||||
<str name="name">default</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<str name="spellcheckIndexDir">spellchecker1</str>
|
||||
<str name="buildOnCommit">false</str>
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<lst name="spellchecker">
|
||||
<str name="name">direct</str>
|
||||
<str name="classname">DirectSolrSpellChecker</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<str name="field">a_s</str>
|
||||
<int name="minQueryLength">3</int>
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<str name="name">wordbreak</str>
|
||||
<str name="classname">solr.WordBreakSolrSpellChecker</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<str name="combineWords">true</str>
|
||||
<str name="breakWords">true</str>
|
||||
<int name="maxChanges">10</int>
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<str name="name">multipleFields</str>
|
||||
<str name="field">lowerfilt1and2</str>
|
||||
<str name="spellcheckIndexDir">spellcheckerMultipleFields</str>
|
||||
<str name="buildOnCommit">false</str>
|
||||
</lst>
|
||||
<!-- Example of using different distance measure -->
|
||||
<lst name="spellchecker">
|
||||
<str name="name">jarowinkler</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<!-- Use a different Distance Measure -->
|
||||
<str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
|
||||
<str name="spellcheckIndexDir">spellchecker2</str>
|
||||
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<str name="classname">solr.FileBasedSpellChecker</str>
|
||||
<str name="name">external</str>
|
||||
<str name="sourceLocation">spellings.txt</str>
|
||||
<str name="characterEncoding">UTF-8</str>
|
||||
<str name="spellcheckIndexDir">spellchecker3</str>
|
||||
</lst>
|
||||
<!-- Comparator -->
|
||||
<lst name="spellchecker">
|
||||
<str name="name">freq</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<str name="spellcheckIndexDir">spellcheckerFreq</str>
|
||||
<!-- comparatorClass be one of:
|
||||
1. score (default)
|
||||
2. freq (Frequency first, then score)
|
||||
3. A fully qualified class name
|
||||
-->
|
||||
<str name="comparatorClass">freq</str>
|
||||
<str name="buildOnCommit">false</str>
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<str name="name">fqcn</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
<str name="spellcheckIndexDir">spellcheckerFQCN</str>
|
||||
<str name="comparatorClass">org.apache.solr.spelling.SampleComparator</str>
|
||||
<str name="buildOnCommit">false</str>
|
||||
</lst>
|
||||
<lst name="spellchecker">
|
||||
<str name="name">perDict</str>
|
||||
<str name="classname">org.apache.solr.handler.component.DummyCustomParamSpellChecker</str>
|
||||
<str name="field">lowerfilt</str>
|
||||
</lst>
|
||||
</searchComponent>
|
||||
|
||||
<searchComponent name="termsComp" class="org.apache.solr.handler.component.TermsComponent"/>
|
||||
|
@ -323,19 +262,6 @@ based HashBitset. -->
|
|||
-->
|
||||
<queryConverter name="queryConverter" class="org.apache.solr.spelling.SpellingQueryConverter"/>
|
||||
|
||||
<requestHandler name="spellCheckCompRH" class="org.apache.solr.handler.component.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<!-- omp = Only More Popular -->
|
||||
<str name="spellcheck.onlyMorePopular">false</str>
|
||||
<!-- exr = Extended Results -->
|
||||
<str name="spellcheck.extendedResults">false</str>
|
||||
<!-- The number of suggestions to return -->
|
||||
<str name="spellcheck.count">1</str>
|
||||
</lst>
|
||||
<arr name="last-components">
|
||||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
<requestHandler name="spellCheckCompRH_Direct" class="org.apache.solr.handler.component.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<str name="spellcheck.dictionary">direct</str>
|
||||
|
@ -347,35 +273,6 @@ based HashBitset. -->
|
|||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
<requestHandler name="spellCheckWithWordbreak" class="org.apache.solr.handler.component.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<str name="spellcheck.dictionary">default</str>
|
||||
<str name="spellcheck.dictionary">wordbreak</str>
|
||||
<str name="spellcheck.count">20</str>
|
||||
</lst>
|
||||
<arr name="last-components">
|
||||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
<requestHandler name="spellCheckWithWordbreak_Direct" class="org.apache.solr.handler.component.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<str name="spellcheck.dictionary">direct</str>
|
||||
<str name="spellcheck.dictionary">wordbreak</str>
|
||||
<str name="spellcheck.count">20</str>
|
||||
</lst>
|
||||
<arr name="last-components">
|
||||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
<requestHandler name="spellCheckCompRH1" class="org.apache.solr.handler.component.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<str name="defType">dismax</str>
|
||||
<str name="qf">lowerfilt1^1</str>
|
||||
</lst>
|
||||
<arr name="last-components">
|
||||
<str>spellcheck</str>
|
||||
</arr>
|
||||
</requestHandler>
|
||||
|
||||
<requestHandler name="mltrh" class="org.apache.solr.handler.component.SearchHandler">
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.spelling;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.SpellingParams;
|
||||
import org.apache.solr.handler.component.SpellCheckComponent;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SpellCheckCollatorWithCollapseTest extends SolrTestCaseJ4 {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig-collapseqparser.xml", "schema11.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
clearIndex();
|
||||
assertU(commit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
for(int i=0 ; i<200 ; i++) {
|
||||
String[] doc = {"id","" + i, "group_i", "" + (i % 10), "a_s", ((i%2)==0 ? "love" : "peace")};
|
||||
assertU(adoc(doc));
|
||||
if(i%5==0) {
|
||||
assertU(commit());
|
||||
}
|
||||
}
|
||||
assertU(commit());
|
||||
assertQ(
|
||||
req(
|
||||
SpellCheckComponent.COMPONENT_NAME, "true",
|
||||
SpellCheckComponent.SPELLCHECK_DICT, "direct",
|
||||
SpellingParams.SPELLCHECK_COUNT, "10",
|
||||
SpellingParams.SPELLCHECK_COLLATE, "true",
|
||||
SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5",
|
||||
SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1",
|
||||
CommonParams.Q, "a_s:lpve",
|
||||
CommonParams.QT, "spellCheckCompRH_Direct",
|
||||
SpellingParams.SPELLCHECK_COLLATE_MAX_COLLECT_DOCS, "5",
|
||||
CommonParams.FQ, "{!collapse field=group_i}",
|
||||
"expand", "true"),
|
||||
"//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='a_s:love'");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue