Refreshing after green so also recovering replicas will be refreshed.
This commit is contained in:
parent
e6dcd137a6
commit
45d4864021
|
@ -30,8 +30,7 @@ import org.junit.Test;
|
|||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class SimpleSearchTests extends AbstractSharedClusterTest {
|
||||
|
@ -39,14 +38,14 @@ public class SimpleSearchTests extends AbstractSharedClusterTest {
|
|||
@Test
|
||||
public void testSearchNullIndex() {
|
||||
try {
|
||||
client().prepareSearch((String)null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
|
||||
client().prepareSearch((String) null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
|
||||
assert false;
|
||||
} catch (ElasticSearchIllegalArgumentException e) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
client().prepareSearch((String[])null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
|
||||
client().prepareSearch((String[]) null).setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
|
||||
assert false;
|
||||
} catch (ElasticSearchIllegalArgumentException e) {
|
||||
|
||||
|
@ -115,8 +114,8 @@ public class SimpleSearchTests extends AbstractSharedClusterTest {
|
|||
prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.mapping.date.parse_upper_inclusive", false)).execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "1").setSource("field", "2010-01-05T02:00").execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "2").setSource("field", "2010-01-06T02:00").execute().actionGet();
|
||||
refresh();
|
||||
ensureGreen();
|
||||
refresh();
|
||||
// test include upper on ranges to include the full day on the upper bound (disabled here though...)
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-05").lte("2010-01-06")).execute().actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
|
@ -130,8 +129,8 @@ public class SimpleSearchTests extends AbstractSharedClusterTest {
|
|||
prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder()).execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "1").setSource("field", "2010-01-05T02:00").execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "2").setSource("field", "2010-01-06T02:00").execute().actionGet();
|
||||
refresh();
|
||||
ensureGreen();
|
||||
refresh();
|
||||
SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d")).execute().actionGet();
|
||||
assertNoFailures(searchResponse);
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(2l));
|
||||
|
@ -158,8 +157,8 @@ public class SimpleSearchTests extends AbstractSharedClusterTest {
|
|||
.execute().actionGet();
|
||||
ensureGreen();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
client().prepareIndex("test", "type1", ""+i).setSource("date_field", "Mi, 06 Dez 2000 02:55:00 -0800").execute().actionGet();
|
||||
client().prepareIndex("test", "type1", ""+(10+i)).setSource("date_field", "Do, 07 Dez 2000 02:55:00 -0800").execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "" + i).setSource("date_field", "Mi, 06 Dez 2000 02:55:00 -0800").execute().actionGet();
|
||||
client().prepareIndex("test", "type1", "" + (10 + i)).setSource("date_field", "Do, 07 Dez 2000 02:55:00 -0800").execute().actionGet();
|
||||
}
|
||||
|
||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||
|
@ -170,7 +169,7 @@ public class SimpleSearchTests extends AbstractSharedClusterTest {
|
|||
assertThat(searchResponse.getHits().totalHits(), equalTo(10l));
|
||||
|
||||
searchResponse = client().prepareSearch("test")
|
||||
.setQuery(QueryBuilders.rangeQuery("date_field").gte( "Di, 05 Dez 2000 02:55:00 -0800").lte("Fr, 08 Dez 2000 00:00:00 -0800"))
|
||||
.setQuery(QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Fr, 08 Dez 2000 00:00:00 -0800"))
|
||||
.execute().actionGet();
|
||||
assertThat(searchResponse.getHits().totalHits(), equalTo(20l));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue