use of io.zulia.client.command.builder.TermQuery in project zuliasearch by zuliaio.
the class StartStopTest method termTestBuilder.
@Test
@Order(3)
public void termTestBuilder() throws Exception {
Search s = new Search(FACET_TEST_INDEX);
s.addQuery(new TermQuery("id").addTerms("1", "2", "3", "4"));
SearchResult searchResult = zuliaWorkPool.search(s);
Assertions.assertEquals(4, searchResult.getTotalHits());
s = new Search(FACET_TEST_INDEX);
s.addQuery(new TermQuery("id").addTerms(Arrays.asList("1", "2", "3", "4")));
s.addQuery(new FilterQuery("testBool:true"));
searchResult = zuliaWorkPool.search(s);
Assertions.assertEquals(4, searchResult.getTotalHits());
s = new Search(FACET_TEST_INDEX);
s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4"));
s.addQuery(new FilterQuery("country:US"));
searchResult = zuliaWorkPool.search(s);
Assertions.assertEquals(2, searchResult.getTotalHits());
s = new Search(FACET_TEST_INDEX);
s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4").exclude());
s.addQuery(new FilterQuery("country:US"));
searchResult = zuliaWorkPool.search(s);
Assertions.assertEquals(28, searchResult.getTotalHits());
s = new Search(FACET_TEST_INDEX);
s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4").exclude());
s.addQuery(new FilterQuery("country:US").exclude());
// need to use match all because all other queries are negated
s.addQuery(new MatchAllQuery());
searchResult = zuliaWorkPool.search(s);
Assertions.assertEquals(28, searchResult.getTotalHits());
}
Aggregations