From 4145d154bbb71a52f6ec8e00b52f9297888993e2 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 25 Feb 2013 11:58:58 +0100 Subject: [PATCH] add a test for empty lookup terms filter --- .../test/integration/search/query/SimpleQueryTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java index 41834d3971f..007c542abe7 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.index.query.CommonTermsQueryBuilder.Operator; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.facet.FacetBuilders; import org.elasticsearch.test.integration.AbstractNodesTests; -import org.hamcrest.Matchers; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -714,6 +713,7 @@ public class SimpleQueryTests extends AbstractNodesTests { client.prepareIndex("lookup", "type", "1").setSource("terms", new String[]{"1", "3"}).execute().actionGet(); client.prepareIndex("lookup", "type", "2").setSource("terms", new String[]{"2"}).execute().actionGet(); client.prepareIndex("lookup", "type", "3").setSource("terms", new String[]{"2", "4"}).execute().actionGet(); + client.prepareIndex("lookup", "type", "4").setSource("other", "value").execute().actionGet(); client.prepareIndex("lookup2", "type", "1").setSource(XContentFactory.jsonBuilder().startObject() .startArray("arr") @@ -772,6 +772,12 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.getHits().getHits()[0].getId(), anyOf(equalTo("2"), equalTo("4"))); assertThat(searchResponse.getHits().getHits()[1].getId(), anyOf(equalTo("2"), equalTo("4"))); + searchResponse = client.prepareSearch("test") + .setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("4").lookupPath("terms")) + ).execute().actionGet(); + assertThat("Failures " + Arrays.toString(searchResponse.getShardFailures()), searchResponse.getShardFailures().length, equalTo(0)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + searchResponse = client.prepareSearch("test") .setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup2").lookupType("type").lookupId("1").lookupPath("arr.term"))