SOLR-13944: remove redundant checks in SpellCheckCollator

* After SOLR-14073, these checks become redundant and add
  additional tests for spellcheck with collapse
This commit is contained in:
Munendra S N 2020-03-18 10:51:50 +05:30
parent 0b063fd2b7
commit 7f37a55a8c
3 changed files with 28 additions and 26 deletions

View File

@ -78,6 +78,9 @@ Other Changes
* SOLR-10157: Improve error messages when unknown aggregations are specified in the request (hossman, Munendra S N)
* SOLR-13944: Remove redundant checks in SpellCheckCollator and add tests for spellcheck with collapse
(Stefan, Munendra S N, Tomas Eduardo Fernandez Lobbe)
================== 8.5.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -134,25 +134,15 @@ public class SpellCheckCollator {
// 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),
new SolrQueryResponse(), Arrays.<SearchComponent> asList(queryComponent));
new SolrQueryResponse(), Arrays.asList(queryComponent));
checkResponse.setQparser(ultimateResponse.getQparser());
checkResponse.setFilters(ultimateResponse.getFilters());
checkResponse.setQueryString(collationQueryStr);
checkResponse.components = Arrays.<SearchComponent>asList(queryComponent);
checkResponse.components = Arrays.asList(queryComponent);
try {
queryComponent.prepare(checkResponse);

View File

@ -18,6 +18,7 @@ package org.apache.solr.spelling;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.SpellingParams;
import org.apache.solr.handler.component.SpellCheckComponent;
import org.junit.Before;
@ -48,8 +49,15 @@ public class SpellCheckCollatorWithCollapseTest extends SolrTestCaseJ4 {
}
}
assertU(commit());
for (SolrParams params : new SolrParams[]{
params(CommonParams.FQ, "{!collapse field=group_i}"),
params(CommonParams.FQ, "${bleh}", "bleh", "{!collapse field=group_i}"), // substitution
params(CommonParams.FQ, "{!tag=collapser}{!collapse field=group_i}"), // with tag & collapse in localparams
params(CommonParams.FQ, "{!collapse tag=collapser field=group_i}")
}) {
assertQ(
req(
req(params,
SpellCheckComponent.COMPONENT_NAME, "true",
SpellCheckComponent.SPELLCHECK_DICT, "direct",
SpellingParams.SPELLCHECK_COUNT, "10",
@ -59,9 +67,10 @@ public class SpellCheckCollatorWithCollapseTest extends SolrTestCaseJ4 {
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'");
"//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='a_s:love'"
);
}
}
}