SOLR-8988: Adds query option facet.distrib.mco which when set to true allows the use of facet.mincount=1 in cloud mode

This commit is contained in:
Dennis Gove 2016-05-23 15:13:37 -04:00
parent 1b809e784a
commit e4e990b993
4 changed files with 43 additions and 4 deletions

View File

@ -142,6 +142,9 @@ New Features
* SOLR-8323, SOLR-9113: Add CollectionStateWatcher API (Alan Woodward, Scott Blum)
* SOLR-8988: Adds query option facet.distrib.mco which when set to true allows the use of facet.mincount=1 in cloud mode.
(Keith Laban, Dennis Gove)
Bug Fixes
----------------------

View File

@ -563,9 +563,16 @@ public class FacetComponent extends SearchComponent {
// set the initial limit higher to increase accuracy
dff.initialLimit = doOverRequestMath(dff.initialLimit, dff.overrequestRatio,
dff.overrequestCount);
dff.initialMincount = 0; // TODO: we could change this to 1, but would
// then need more refinement for small facet
// result sets?
// If option FACET_DISTRIB_MCO is turned on then we will use 1 as the initial
// minCount (unless the user explicitly set it to something less than 1). If
// option FACET_DISTRIB_MCO is turned off then we will use 0 as the initial
// minCount regardless of what the user might have provided (prior to the
// addition of the FACET_DISTRIB_MCO option the default logic was to use 0).
// As described in issues SOLR-8559 and SOLR-8988 the use of 1 provides a
// significant performance boost.
dff.initialMincount = dff.mco ? Math.min(dff.minCount, 1) : 0;
} else {
// if limit==-1, then no need to artificially lower mincount to 0 if
// it's 1
@ -1415,6 +1422,7 @@ public class FacetComponent extends SearchComponent {
public int initialLimit; // how many terms requested in first phase
public int initialMincount; // mincount param sent to each shard
public boolean mco;
public double overrequestRatio;
public int overrequestCount;
public boolean needRefinements;
@ -1434,6 +1442,8 @@ public class FacetComponent extends SearchComponent {
this.overrequestCount
= params.getFieldInt(field, FacetParams.FACET_OVERREQUEST_COUNT, 10);
this.mco
= params.getFieldBool(field, FacetParams.FACET_DISTRIB_MCO, false);
}
void add(int shardNum, NamedList shardCounts, int numRequested) {

View File

@ -53,6 +53,7 @@ import static org.apache.solr.common.params.FacetParams.FACET_OVERREQUEST_RATIO;
import static org.apache.solr.common.params.FacetParams.FACET_PIVOT;
import static org.apache.solr.common.params.FacetParams.FACET_PIVOT_MINCOUNT;
import static org.apache.solr.common.params.FacetParams.FACET_SORT;
import static org.apache.solr.common.params.FacetParams.FACET_DISTRIB_MCO;
/**
* <p>
@ -84,6 +85,8 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
// param used by test purely for tracing & validation
private static String TRACE_MIN = "_test_min";
// param used by test purely for tracing & validation
private static String TRACE_DISTRIB_MIN = "_test_distrib_min";
// param used by test purely for tracing & validation
private static String TRACE_MISS = "_test_miss";
// param used by test purely for tracing & validation
private static String TRACE_SORT = "_test_sort";
@ -191,6 +194,12 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
baseP.add(TRACE_MIN, min);
}
if (random().nextBoolean()) {
pivotP.add(FACET_DISTRIB_MCO, "true");
// trace param for validation
baseP.add(TRACE_DISTRIB_MIN, "true");
}
if (random().nextBoolean()) {
String missing = ""+random().nextBoolean();
pivotP.add(FACET_MISSING, missing);

View File

@ -122,6 +122,23 @@ public interface FacetParams {
public static final String FACET_OVERREQUEST_COUNT = FACET_OVERREQUEST + ".count";
public static final String FACET_DISTRIB = FACET + ".distrib";
/**
* If we are returning facet field counts, are sorting those facets by their count, and the minimum count to return is &gt; 0,
* then allow the use of facet.mincount = 1 in cloud mode. To enable this use facet.distrib.mco=true.
*
* i.e. If the following three conditions are met in cloud mode: facet.sort=count, facet.limit &gt; 0, facet.mincount &gt; 0.
* Then use facet.mincount=1.
*
* Previously and by default facet.mincount will be explicitly set to 0 when in cloud mode for this condition.
* In SOLR-8599 and SOLR-8988, significant performance increase has been seen when enabling this optimization.
*
* Note: enabling this flag has no effect when the conditions above are not met. For those other cases the default behavior is sufficient.
*/
public static final String FACET_DISTRIB_MCO = FACET_DISTRIB + ".mco";
/**
* Comma separated list of fields to pivot
*