Lucene's SortedSetDocValues got a new SortedSetDocValues#docValueCount API that allows getting the number of values of a document without iterating through all values. We should change the iteration logic to use this count and consume count ords instead of iterating all ords until NO_MORE_ORDS is returned.
This should speed up some queries, e.g. value_count aggregations through the refactoring of FieldData#toString(SortedSetDocValues) to not iterate through all values to figure out the number of values.
Description
Lucene's
SortedSetDocValues
got a newSortedSetDocValues#docValueCount
API that allows getting the number of values of a document without iterating through all values. We should change the iteration logic to use this count and consumecount
ords instead of iterating all ords untilNO_MORE_ORDS
is returned.This should speed up some queries, e.g.
value_count
aggregations through the refactoring ofFieldData#toString(SortedSetDocValues)
to not iterate through all values to figure out the number of values.