[TEST] top_hits aggs with breath_first collect mode only fails if scoring is used (score based sort or track_scores)

This commit is contained in:
Martijn van Groningen 2014-07-21 11:21:50 +02:00
parent ba1042e7d1
commit f3114fe774
1 changed files with 13 additions and 3 deletions

View File

@ -413,15 +413,25 @@ public class TopHitsTests extends ElasticsearchIntegrationTest {
} }
@Test @Test
public void testFailDeferred() throws Exception { public void testFailDeferredOnlyWhenScorerIsUsed() throws Exception {
// No track_scores or score based sort defined in top_hits agg, so don't fail:
SearchResponse response = client().prepareSearch("idx")
.setTypes("type")
.addAggregation(
terms("terms").executionHint(randomExecutionHint()).field(TERMS_AGGS_FIELD)
.collectMode(SubAggCollectionMode.BREADTH_FIRST)
.subAggregation(topHits("hits").addSort(SortBuilders.fieldSort(SORT_FIELD).order(SortOrder.DESC))))
.get();
assertSearchResponse(response);
// Score based, so fail with deferred aggs:
try { try {
client().prepareSearch("idx") client().prepareSearch("idx")
.setTypes("type") .setTypes("type")
.addAggregation( .addAggregation(
terms("terms").executionHint(randomExecutionHint()).field(TERMS_AGGS_FIELD) terms("terms").executionHint(randomExecutionHint()).field(TERMS_AGGS_FIELD)
.collectMode(SubAggCollectionMode.BREADTH_FIRST) .collectMode(SubAggCollectionMode.BREADTH_FIRST)
.subAggregation(topHits("hits").addSort(SortBuilders.fieldSort(SORT_FIELD).order(SortOrder.DESC)))) .subAggregation(topHits("hits")))
.get(); .get();
fail(); fail();
} catch (Exception e) { } catch (Exception e) {