Skip to content

Commit

Permalink
Aggregations: Fix geohash grid doc counts computation on multi-valued…
Browse files Browse the repository at this point in the history
… fields.

Close #8512
  • Loading branch information
jpountz committed Nov 21, 2014
1 parent 92fc698 commit 0486c20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Expand Up @@ -73,14 +73,18 @@ public void collect(int doc, long owningBucketOrdinal) throws IOException {
values.setDocument(doc);
final int valuesCount = values.count();

long previous = Long.MAX_VALUE;
for (int i = 0; i < valuesCount; ++i) {
final long val = values.valueAt(i);
long bucketOrdinal = bucketOrds.add(val);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
if (previous != val || i == 0) {
long bucketOrdinal = bucketOrds.add(val);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
}
previous = val;
}
}
}
Expand Down
Expand Up @@ -106,9 +106,7 @@ public void setupSuiteScopeCluster() throws Exception {
for (int i = 0; i < numDocs; i++) {
final int numPoints = random.nextInt(4);
List<String> points = new ArrayList<>();
// TODO (#8512): this should be a Set, not a List. Currently if a document has two positions that have
// the same geo hash, it will increase the doc_count for this geo hash by 2 instead of 1
List<String> geoHashes = new ArrayList<>();
Set<String> geoHashes = new HashSet<>();
for (int j = 0; j < numPoints; ++j) {
double lat = (180d * random.nextDouble()) - 90d;
double lng = (360d * random.nextDouble()) - 180d;
Expand Down

0 comments on commit 0486c20

Please sign in to comment.