SOLR-10033: When attempting to facet with facet.mincount=0 over points fields, raise mincount to 1 and log a warning.

This commit is contained in:
Steve Rowe 2017-08-01 15:32:54 -04:00
parent d696b5986b
commit 6b399d7a61
4 changed files with 13 additions and 6 deletions

View File

@ -604,6 +604,9 @@ Other Changes
* SOLR-9321: Remove deprecated methods of ClusterState. (Jason Gerlowski, ishan, Cao Manh Dat)
* SOLR-10033: When attempting to facet with facet.mincount=0 over points fields, raise mincount to 1
and log a warning. (Steve Rowe)
================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -407,7 +407,7 @@ final class NumericFacets {
private static NamedList<Integer> getCountsMultiValued(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort) throws IOException {
// If facet.mincount=0 with PointFields the only option is to get the values from DocValues
// not currently supported. See SOLR-10033
// not currently supported. See SOLR-11174
mincount = Math.max(mincount, 1);
final SchemaField sf = searcher.getSchema().getField(fieldName);
final FieldType ft = sf.getType();

View File

@ -17,6 +17,7 @@
package org.apache.solr.request;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -93,6 +94,8 @@ import org.apache.solr.search.grouping.GroupingSpecification;
import org.apache.solr.util.BoundedTreeSet;
import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.RTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.common.params.CommonParams.SORT;
@ -103,6 +106,7 @@ import static org.apache.solr.common.params.CommonParams.SORT;
* to leverage any of its functionality.
*/
public class SimpleFacets {
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/** The main set of documents all facet counts should be relative to */
protected DocSet docsOrig;
@ -492,10 +496,10 @@ public class SimpleFacets {
+ FacetParams.FACET_CONTAINS + ", "
+ FacetParams.FACET_EXCLUDETERMS + ") are not supported on numeric types");
}
// We should do this, but mincount=0 is currently the default
// if (ft.isPointField() && mincount <= 0) {
// throw new SolrException(ErrorCode.BAD_REQUEST, FacetParams.FACET_MINCOUNT + " <= 0 is not supported on point 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.");
mincount = 1;
}
counts = NumericFacets.getCounts(searcher, docs, field, offset, limit, mincount, missing, sort);
} else {
PerSegmentSingleValuedFaceting ps = new PerSegmentSingleValuedFaceting(searcher, docs, field, offset, limit, mincount, missing, sort, prefix, termFilter);

View File

@ -335,7 +335,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
@Test
public void testFacetSortWithMinCount0() {
assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-10033) or single valued DV",
assumeFalse("facet.mincount=0 doesn't work with point fields (SOLR-11174) or single valued DV",
Boolean.getBoolean(NUMERIC_POINTS_SYSPROP) || Boolean.getBoolean(NUMERIC_DOCVALUES_SYSPROP));
assertU(adoc("id", "1", "f_td", "-420.126"));