I am developing a custom aggregator using ES 1.3.4. It extends from
NumericMetricsAggregator.MultiValue class. Its code structure closely
resembles that of the Stats aggregator. For my requirements, I need the doc
Ids to be received in ascending order in the overridden collect() method.
For most queries, I do get the doc Ids in ascending order. Interestingly
for bool should queries with multiple clauses, I get doc Ids in descending
order. How can I fix this? Is this a bug?
I asked the same question on github and got the answer which worked for me.
Here's the solution:
You can call aggregationContext.ensureScoreDocsInOrder(); to make sure that
docs are going to come in order, have a look for instance at
ReverseNestedAggregator which uses this method.
Queries are indeed allowed to emit documents out-of-order if allowed to do
so and if it makes things faster. I believe the only case when it happens
today is when you get Lucene's BooleanScorer which is used for top-level
disjunctions, so your observation makes sense.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.