Skip to content

Commit dbd372c

Browse files
committed
[TEST] Added IntegrationTest to reproduce #6614
1 parent 06918d5 commit dbd372c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/java/org/elasticsearch/search/sort/SimpleSortTests.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,43 @@
6161
*/
6262
public class SimpleSortTests extends ElasticsearchIntegrationTest {
6363

64+
65+
public void testIssue6614() throws ExecutionException, InterruptedException {
66+
List<IndexRequestBuilder> builders = new ArrayList<>();
67+
boolean strictTimeBasedIndices = randomBoolean();
68+
final int numIndices = randomIntBetween(2, 25); // at most 25 days in the month
69+
for (int i = 0; i < numIndices; i++) {
70+
final String indexId = strictTimeBasedIndices ? "idx_" + i : "idx";
71+
if (strictTimeBasedIndices || i == 0) {
72+
createIndex(indexId);
73+
}
74+
final int numDocs = randomIntBetween(1, 23); // hour of the day
75+
for (int j = 0; j < numDocs; j++) {
76+
builders.add(client().prepareIndex(indexId, "type").setSource("foo", "bar", "timeUpdated", "2014/07/" + String.format(Locale.ROOT, "%02d", i+1)+" " + String.format(Locale.ROOT, "%02d", j+1) + ":00:00"));
77+
}
78+
}
79+
int docs = builders.size();
80+
indexRandom(true, builders);
81+
SearchResponse allDocsResponse = client().prepareSearch().setQuery(QueryBuilders.filteredQuery(matchAllQuery(),
82+
FilterBuilders.boolFilter().must(FilterBuilders.termFilter("foo", "bar"),
83+
FilterBuilders.rangeFilter("timeUpdated").gte("2014/0" + randomIntBetween(1, 7) + "/01").cache(randomBoolean()))))
84+
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).ignoreUnmapped(true))
85+
.setSize(docs).get();
86+
87+
final int numiters = randomIntBetween(1, 20);
88+
for (int i = 0; i < numiters; i++) {
89+
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.filteredQuery(matchAllQuery(),
90+
FilterBuilders.boolFilter().must(FilterBuilders.termFilter("foo", "bar"),
91+
FilterBuilders.rangeFilter("timeUpdated").gte("2014/" + String.format(Locale.ROOT, "%02d", randomIntBetween(1, 7)) + "/01").cache(randomBoolean()))))
92+
.addSort(new FieldSortBuilder("timeUpdated").order(SortOrder.ASC).ignoreUnmapped(true))
93+
.setSize(scaledRandomIntBetween(1, docs)).get();
94+
for (int j = 0; j < searchResponse.getHits().hits().length; j++) {
95+
assertThat(searchResponse.toString() + "\n vs. \n" + allDocsResponse.toString(), searchResponse.getHits().hits()[j].getId(), equalTo(allDocsResponse.getHits().hits()[j].getId()));
96+
}
97+
}
98+
99+
}
100+
64101
public void testIssue6639() throws ExecutionException, InterruptedException {
65102
assertAcked(prepareCreate("$index")
66103
.addMapping("$type","{\"$type\": {\"_boost\": {\"name\": \"boost\", \"null_value\": 1.0}, \"properties\": {\"grantee\": {\"index\": \"not_analyzed\", \"term_vector\": \"with_positions_offsets\", \"type\": \"string\", \"analyzer\": \"snowball\", \"boost\": 1.0, \"store\": \"yes\"}}}}"));

0 commit comments

Comments
 (0)