add empty index test

This commit is contained in:
kimchy 2011-07-08 08:02:34 +03:00
parent 5a8b27b9dc
commit 893c7df966
1 changed files with 8 additions and 1 deletions

View File

@ -69,6 +69,13 @@ public class SimpleNestedTests extends AbstractNodesTests {
client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
// check on no data, see it works
SearchResponse searchResponse = client.prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(0l));
searchResponse = client.prepareSearch("test").setQuery(termQuery("nested1.n_field1", "n_value1_1")).execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(0l));
client.prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
.field("field1", "value1")
.startArray("nested1")
@ -93,7 +100,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(3));
// check that _all is working on nested docs
SearchResponse searchResponse = client.prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
searchResponse = client.prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
searchResponse = client.prepareSearch("test").setQuery(termQuery("nested1.n_field1", "n_value1_1")).execute().actionGet();
assertThat(searchResponse.hits().totalHits(), equalTo(0l));