Is your feature request related to a problem? Please describe
In #13821, we introduced "Support Dynamic Pruning in Cardinality Aggregation", once we collect one document, we will not collect the values of this document anymore in cardinality aggregation. However, the ScoreMode is set to COMPLETE or COMPLETE_NO_SCORES by cardinality aggregation, we have to continue collecting the remaining documents, even if we have already collected the number of documents specified by the totalHitsThreshold.
We can reproduce by the dsl:
POST logs1/_search
{
"query": {
"range": {
"age": {
"from": 1
}
}
},
"aggs": {
"terms1": {
"cardinality": {
"field": "name"
}
}
}
}
Describe the solution you'd like
Once all distinct values have been collected, the cardinality aggregation becomes redundant, and there is no need to traversal the rest of documents. A potential solution is to dynamically adjust the ScoreMode from COMPLETE_NO_SCORES to TOP_SCORES in cardinality aggregation.
Related component
Search:Aggregations
Describe alternatives you've considered
No response
Additional context
No response
Is your feature request related to a problem? Please describe
In #13821, we introduced "Support Dynamic Pruning in Cardinality Aggregation", once we collect one document, we will not collect the values of this document anymore in cardinality aggregation. However, the ScoreMode is set to
COMPLETEorCOMPLETE_NO_SCORESby cardinality aggregation, we have to continue collecting the remaining documents, even if we have already collected the number of documents specified by thetotalHitsThreshold.We can reproduce by the dsl:
Describe the solution you'd like
Once all distinct values have been collected, the cardinality aggregation becomes redundant, and there is no need to traversal the rest of documents. A potential solution is to dynamically adjust the ScoreMode from
COMPLETE_NO_SCOREStoTOP_SCORESin cardinality aggregation.Related component
Search:Aggregations
Describe alternatives you've considered
No response
Additional context
No response