mirror of https://github.com/apache/lucene.git
SOLR-10033: return warning in response header about raising mincount above 0 with points fields
This commit is contained in:
parent
9c154ffbb8
commit
0e2ec280be
|
@ -497,7 +497,16 @@ public class SimpleFacets {
|
|||
+ FacetParams.FACET_EXCLUDETERMS + ") are not supported on numeric types");
|
||||
}
|
||||
if (ft.isPointField() && mincount <= 0) { // default is mincount=0. See SOLR-10033 & SOLR-11174.
|
||||
LOG.warn("Raising facet.mincount from " + mincount + " to 1, because field " + field + " is Points-based.");
|
||||
String warningMessage
|
||||
= "Raising facet.mincount from " + mincount + " to 1, because field " + field + " is Points-based.";
|
||||
LOG.warn(warningMessage);
|
||||
List<String> warnings = (List<String>)rb.rsp.getResponseHeader().get("warnings");
|
||||
if (null == warnings) {
|
||||
warnings = new ArrayList<>();
|
||||
rb.rsp.getResponseHeader().add("warnings", warnings);
|
||||
}
|
||||
warnings.add(warningMessage);
|
||||
|
||||
mincount = 1;
|
||||
}
|
||||
counts = NumericFacets.getCounts(searcher, docs, field, offset, limit, mincount, missing, sort);
|
||||
|
|
|
@ -356,8 +356,28 @@ public class TestFaceting extends SolrTestCaseJ4 {
|
|||
"//lst[@name='facet_fields']/lst[@name='f_td']/int[3][@name='-1.218']");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFacetOverPointFieldWithMinCount0() {
|
||||
String field = "f_" + new String[]{"i","l","f","d"}[random().nextInt(4)] + "_p";
|
||||
String expectedWarning = "Raising facet.mincount from 0 to 1, because field " + field + " is Points-based.";
|
||||
SolrQueryRequest req = req("q", "id:1.0",
|
||||
FacetParams.FACET, "true",
|
||||
FacetParams.FACET_FIELD, field,
|
||||
FacetParams.FACET_MINCOUNT, "0");
|
||||
assertQ(req
|
||||
, "/response/lst[@name='responseHeader']/arr[@name='warnings']/str[.='" + expectedWarning + "']");
|
||||
|
||||
field = "f_" + new String[]{"is","ls","fs","ds"}[random().nextInt(4)] + "_p";
|
||||
expectedWarning = "Raising facet.mincount from 0 to 1, because field " + field + " is Points-based.";
|
||||
req = req("q", "id:1.0",
|
||||
FacetParams.FACET, "true",
|
||||
FacetParams.FACET_FIELD, field,
|
||||
FacetParams.FACET_MINCOUNT, "0");
|
||||
assertQ(req
|
||||
, "/response/lst[@name='responseHeader']/arr[@name='warnings']/str[.='" + expectedWarning + "']");
|
||||
}
|
||||
|
||||
public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
|
||||
public void testSimpleFacetCountsWithMultipleConfigurationsForSameField() {
|
||||
clearIndex();
|
||||
String fname = "trait_ss";
|
||||
assertU(adoc("id", "42",
|
||||
|
|
Loading…
Reference in New Issue