SearchResponse searchResponse = client.prepareSearch()
.setQuery(matchAllQuery())
.addFacet(queryFacet("query").query(termQuery("num", 1)))
.execute().actionGet();
QueryFacet facet = searchResponse.facets().facet("query");
assertThat(facet.count(), equalTo(2l));
searchResponse = client.prepareSearch()
.setQuery(matchAllQuery())
.addFacet(queryFacet("query").query(termQuery("num", 1)).global(true))
.execute().actionGet();
facet = searchResponse.facets().facet("query");
assertThat(facet.count(), equalTo(2l));
searchResponse = client.prepareSearch()
.setQuery(matchAllQuery())
.addFacet(queryFacet("query").query(termsQuery("num", new long[]{1, 2})).facetFilter(termFilter("num", 1)).global(true))
.execute().actionGet();
facet = searchResponse.facets().facet("query");
assertThat(facet.count(), equalTo(2l));
}
}