SOLR-12539: handle extra spaces in JSON facet shorthand syntax

This commit is contained in:
Munendra S N 2020-11-25 12:21:19 +05:30
parent 0846da5c22
commit d7fd3d8c20
4 changed files with 9 additions and 9 deletions

View File

@ -307,6 +307,9 @@ Bug Fixes
matches the dynamic rule. The copyFields are rebuilt with replace-field and replace-field-type, if required
(Andrew Shumway, Munendra S N)
* SOLR-12539: Handle parsing of values for 'other', 'include', and 'excludeTags' in JSON facets when specified as
comma-separated values with extra spaces (hossman, Munendra S N)
Other Changes
---------------------

View File

@ -20,6 +20,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.SolrParams;
@ -388,8 +389,10 @@ abstract class FacetParser<FacetRequestT extends FacetRequest> {
return (List<String>)o;
}
if (o instanceof String) {
// TODO: SOLR-12539 handle spaces in b/w comma & value ie, should the values be trimmed before returning??
return StrUtils.splitSmart((String)o, ",", decode);
return StrUtils.splitSmart((String)o, ",", decode).stream()
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}
throw err("Expected list of string or comma separated string values for '" + paramName +

View File

@ -936,12 +936,6 @@ public class RangeFacetCloudTest extends SolrCloudTestCase {
// - a JSON list of items (conveniently the default toString of EnumSet),
// - a single quoted string containing the comma separated list
val = val.replaceAll("\\[|\\]","'");
// HACK: work around SOLR-12539...
//
// when sending a single string containing a comma separated list of values, JSON Facets 'other'
// parsing can't handle any leading (or trailing?) whitespace
val = val.replaceAll("\\s","");
}
return ", other:" + val;
}