|
24 | 24 | import org.elasticsearch.common.geo.GeoPoint;
|
25 | 25 | import org.elasticsearch.common.settings.ImmutableSettings;
|
26 | 26 | import org.elasticsearch.common.util.BigArray;
|
| 27 | +import org.elasticsearch.search.SearchHitField; |
27 | 28 | import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
28 | 29 | import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
29 | 30 | import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;
|
30 | 31 | import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsAggregator;
|
| 32 | +import org.elasticsearch.search.sort.SortBuilders; |
| 33 | +import org.elasticsearch.search.sort.SortOrder; |
31 | 34 | import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
32 | 35 | import org.junit.Test;
|
33 | 36 |
|
@@ -142,9 +145,21 @@ public void setupSuiteScopeCluster() throws Exception {
|
142 | 145 | .field("tag", "tag" + i)
|
143 | 146 | .endObject()));
|
144 | 147 | }
|
145 |
| - |
| 148 | + |
146 | 149 | indexRandom(true, builders);
|
147 | 150 | ensureSearchable();
|
| 151 | + |
| 152 | + // Added to debug a test failure (Dev issue #266) where the terms aggregation seems to be reporting two documents with the same value for NUMBER_FIELD_NAME. This will chaeck that after |
| 153 | + // random indexing each document only has 1 value for NUMBER_FIELD_NAME and it is the correct value |
| 154 | + SearchResponse response = client().prepareSearch("high_card_idx").addField(NUMBER_FIELD_NAME).addSort(SortBuilders.fieldSort(NUMBER_FIELD_NAME).order(SortOrder.ASC)).setSize(5000).get(); |
| 155 | + assertSearchResponse(response); |
| 156 | + assertThat(response.getHits().totalHits(), equalTo(2000l)); |
| 157 | + for (int i = 0; i < 2000; i++) { |
| 158 | + SearchHitField hitField = response.getHits().getAt(i).field(NUMBER_FIELD_NAME); |
| 159 | + assertThat("Hit " + i + " has wrong number of values", hitField.getValues().size(), equalTo(1)); |
| 160 | + Integer value = hitField.getValue(); |
| 161 | + assertThat("Hit " + i + " has wrong value", value, equalTo(i)); |
| 162 | + } |
148 | 163 | }
|
149 | 164 |
|
150 | 165 | private void updateBoundsBottomRight(GeoPoint geoPoint, GeoPoint currentBound) {
|
@@ -335,7 +350,7 @@ public void singleValuedFieldAsSubAggToHighCardTermsAgg() {
|
335 | 350 | for (int i = 0; i < 10; i++) {
|
336 | 351 | Bucket bucket = buckets.get(i);
|
337 | 352 | assertThat(bucket, notNullValue());
|
338 |
| - assertThat(bucket.getDocCount(), equalTo(1l)); |
| 353 | + assertThat("Bucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1l)); |
339 | 354 | GeoBounds geoBounds = bucket.getAggregations().get("geoBounds");
|
340 | 355 | assertThat(geoBounds, notNullValue());
|
341 | 356 | assertThat(geoBounds.getName(), equalTo("geoBounds"));
|
|
0 commit comments