mirror of https://github.com/apache/lucene.git
SOLR-7116: Distrib facet refinement shouldn't re-compute other facet types
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a409e6ed4
commit
7e060ae688
|
@ -150,9 +150,13 @@ Bug Fixes
|
|||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
* SOLR-7049: Move work done by the LIST Collections API call to the Collections
|
||||
Handler (Varun Thacker via Anshum Gupta).
|
||||
|
||||
* SOLR-7116: Distributed facet refinement requests would needlessly compute other types
|
||||
of faceting that have already been computed. (David Smiley, Hossman)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -127,8 +127,10 @@ public class FacetComponent extends SearchComponent {
|
|||
return ResponseBuilder.STAGE_DONE;
|
||||
}
|
||||
|
||||
if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
|
||||
// overlap facet refinement requests (those shards that we need a count
|
||||
if (rb.stage != ResponseBuilder.STAGE_GET_FIELDS) {
|
||||
return ResponseBuilder.STAGE_DONE;
|
||||
}
|
||||
// Overlap facet refinement requests (those shards that we need a count
|
||||
// for particular facet values from), where possible, with
|
||||
// the requests to get fields (because we know that is the
|
||||
// only other required phase).
|
||||
|
@ -138,6 +140,7 @@ public class FacetComponent extends SearchComponent {
|
|||
for (int shardNum = 0; shardNum < rb.shards.length; shardNum++) {
|
||||
List<String> distribFieldFacetRefinements = null;
|
||||
|
||||
// FieldFacetAdditions
|
||||
for (DistribFieldFacet dff : rb._facetInfo.facets.values()) {
|
||||
if (!dff.needRefinements) continue;
|
||||
List<String> refList = dff._toRefine[shardNum];
|
||||
|
@ -169,21 +172,13 @@ public class FacetComponent extends SearchComponent {
|
|||
distribFieldFacetRefinements.add(termsVal);
|
||||
}
|
||||
|
||||
boolean pivotFacetRefinementRequestsExistForShard =
|
||||
doAnyPivotFacetRefinementRequestsExistForShard(rb._facetInfo, shardNum);
|
||||
|
||||
if (distribFieldFacetRefinements == null
|
||||
&& !pivotFacetRefinementRequestsExistForShard) {
|
||||
// nothing to refine, short circuit out
|
||||
continue;
|
||||
}
|
||||
|
||||
if (distribFieldFacetRefinements != null) {
|
||||
String shard = rb.shards[shardNum];
|
||||
ShardRequest shardsRefineRequest = null;
|
||||
boolean newRequest = false;
|
||||
|
||||
// try to find a request that is already going out to that shard.
|
||||
// If nshards becomes to great, we way want to move to hashing for
|
||||
// If nshards becomes too great, we may want to move to hashing for
|
||||
// better scalability.
|
||||
for (ShardRequest sreq : rb.outgoing) {
|
||||
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0
|
||||
|
@ -207,13 +202,9 @@ public class FacetComponent extends SearchComponent {
|
|||
shardsRefineRequest.params.set(CommonParams.ROWS, "0");
|
||||
}
|
||||
|
||||
// FieldFacetAdditions
|
||||
if (distribFieldFacetRefinements != null) {
|
||||
shardsRefineRequest.purpose |= ShardRequest.PURPOSE_REFINE_FACETS;
|
||||
shardsRefineRequest.params.set(FacetParams.FACET, "true");
|
||||
shardsRefineRequest.params.remove(FacetParams.FACET_FIELD);
|
||||
shardsRefineRequest.params.remove(FacetParams.FACET_QUERY);
|
||||
//TODO remove interval faceting, and ranges and heatmap too?
|
||||
removeMainFacetTypeParams(shardsRefineRequest);
|
||||
|
||||
for (int i = 0; i < distribFieldFacetRefinements.size();) {
|
||||
String facetCommand = distribFieldFacetRefinements.get(i++);
|
||||
|
@ -224,27 +215,34 @@ public class FacetComponent extends SearchComponent {
|
|||
facetCommand);
|
||||
shardsRefineRequest.params.set(termsKey, termsVal);
|
||||
}
|
||||
}
|
||||
|
||||
if (newRequest) {
|
||||
rb.addRequest(this, shardsRefineRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PivotFacetAdditions
|
||||
if (pivotFacetRefinementRequestsExistForShard) {
|
||||
if (newRequest) {
|
||||
shardsRefineRequest.params.remove(FacetParams.FACET_PIVOT);
|
||||
shardsRefineRequest.params.remove(FacetParams.FACET_PIVOT_MINCOUNT);
|
||||
}
|
||||
|
||||
if (doAnyPivotFacetRefinementRequestsExistForShard(rb._facetInfo, shardNum)) {
|
||||
enqueuePivotFacetShardRequests(rb, shardNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // for shardNum
|
||||
|
||||
return ResponseBuilder.STAGE_DONE;
|
||||
}
|
||||
|
||||
public static String[] FACET_TYPE_PARAMS = {
|
||||
FacetParams.FACET_FIELD, FacetParams.FACET_PIVOT, FacetParams.FACET_QUERY, FacetParams.FACET_DATE,
|
||||
FacetParams.FACET_RANGE, FacetParams.FACET_INTERVAL, FacetParams.FACET_HEATMAP
|
||||
};
|
||||
|
||||
private void removeMainFacetTypeParams(ShardRequest shardsRefineRequest) {
|
||||
for (String param : FACET_TYPE_PARAMS) {
|
||||
shardsRefineRequest.params.remove(param);
|
||||
}
|
||||
}
|
||||
|
||||
private void enqueuePivotFacetShardRequests(ResponseBuilder rb, int shardNum) {
|
||||
|
||||
FacetInfo fi = rb._facetInfo;
|
||||
|
@ -259,9 +257,8 @@ public class FacetComponent extends SearchComponent {
|
|||
|
||||
shardsRefineRequestPivot.purpose |= ShardRequest.PURPOSE_REFINE_PIVOT_FACETS;
|
||||
shardsRefineRequestPivot.params.set(FacetParams.FACET, "true");
|
||||
shardsRefineRequestPivot.params.remove(FacetParams.FACET_PIVOT_MINCOUNT);
|
||||
removeMainFacetTypeParams(shardsRefineRequestPivot);
|
||||
shardsRefineRequestPivot.params.set(FacetParams.FACET_PIVOT_MINCOUNT, -1);
|
||||
shardsRefineRequestPivot.params.remove(FacetParams.FACET_PIVOT);
|
||||
shardsRefineRequestPivot.params.remove(FacetParams.FACET_OFFSET);
|
||||
|
||||
for (int pivotIndex = 0; pivotIndex < fi.pivotFacets.size(); pivotIndex++) {
|
||||
|
|
Loading…
Reference in New Issue