use of io.zulia.client.command.builder.FilterQuery in project zuliasearch by zuliaio.
the class StatTest method confirm.
@Test
@Order(6)
public void confirm() throws Exception {
Search search = new Search(STAT_TEST_INDEX);
search.addQuery(new FilterQuery("title:boring").exclude());
search.addQuery(new MatchAllQuery());
search.addStat(new NumericStat("authorCount"));
SearchResult searchResult = zuliaWorkPool.search(search);
FacetStats authorCountStats = searchResult.getNumericFieldStat("authorCount");
Assertions.assertEquals(2, authorCountStats.getMin().getLongValue());
Assertions.assertEquals(5, authorCountStats.getMax().getLongValue());
Assertions.assertEquals(20L * repeatCount, authorCountStats.getSum().getLongValue());
Assertions.assertEquals(6L * repeatCount, authorCountStats.getDocCount());
Assertions.assertEquals(6L * repeatCount, authorCountStats.getValueCount());
search.clearStat();
search.addStat(new StatFacet("authorCount", "normalFacet"));
searchResult = zuliaWorkPool.search(search);
List<FacetStats> authorCountByNormalFacet = searchResult.getFacetFieldStat("authorCount", "normalFacet");
for (FacetStats facetStats : authorCountByNormalFacet) {
if (facetStats.getFacet().equals("foo")) {
Assertions.assertEquals(2L, facetStats.getMin().getLongValue());
Assertions.assertEquals(4L, facetStats.getMax().getLongValue());
Assertions.assertEquals(9L * repeatCount, facetStats.getSum().getLongValue());
Assertions.assertEquals(3L * repeatCount, facetStats.getDocCount());
Assertions.assertEquals(3L * repeatCount, facetStats.getAllDocCount());
Assertions.assertEquals(3L * repeatCount, facetStats.getValueCount());
} else if (facetStats.getFacet().equals("bar")) {
Assertions.assertEquals(2L, facetStats.getMin().getLongValue());
Assertions.assertEquals(5L, facetStats.getMax().getLongValue());
Assertions.assertEquals(7L * repeatCount, facetStats.getSum().getLongValue());
Assertions.assertEquals(2L * repeatCount, facetStats.getDocCount());
Assertions.assertEquals(2L * repeatCount, facetStats.getAllDocCount());
Assertions.assertEquals(2L * repeatCount, facetStats.getValueCount());
} else {
throw new AssertionFailedError("Unexpected facet <" + facetStats.getFacet() + ">");
}
}
search.clearStat();
search.addStat(new StatFacet("authorCount", "pathFacet"));
searchResult = zuliaWorkPool.search(search);
List<FacetStats> ratingByPathFacet = searchResult.getFacetFieldStat("authorCount", "pathFacet");
for (FacetStats facetStats : ratingByPathFacet) {
if (facetStats.getFacet().equals("top1")) {
Assertions.assertEquals(2L, facetStats.getMin().getLongValue());
Assertions.assertEquals(4L, facetStats.getMax().getLongValue());
Assertions.assertEquals(9L * repeatCount, facetStats.getSum().getLongValue());
Assertions.assertEquals(3L * repeatCount, facetStats.getDocCount());
Assertions.assertEquals(3L * repeatCount, facetStats.getAllDocCount());
Assertions.assertEquals(3L * repeatCount, facetStats.getValueCount());
} else if (facetStats.getFacet().equals("top2")) {
Assertions.assertEquals(2L, facetStats.getMin().getLongValue());
Assertions.assertEquals(2L, facetStats.getMax().getLongValue());
Assertions.assertEquals(2L * repeatCount, facetStats.getSum().getLongValue());
Assertions.assertEquals(repeatCount, facetStats.getDocCount());
Assertions.assertEquals(repeatCount, facetStats.getAllDocCount());
Assertions.assertEquals(repeatCount, facetStats.getValueCount());
} else if (facetStats.getFacet().equals("top3")) {
Assertions.assertEquals(4L, facetStats.getMin().getLongValue());
Assertions.assertEquals(5L, facetStats.getMax().getLongValue());
Assertions.assertEquals(9L * repeatCount, facetStats.getSum().getLongValue());
Assertions.assertEquals(2L * repeatCount, facetStats.getDocCount());
Assertions.assertEquals(2L * repeatCount, facetStats.getAllDocCount());
Assertions.assertEquals(2L * repeatCount, facetStats.getValueCount());
} else {
throw new AssertionFailedError("Unexpected facet <" + facetStats.getFacet() + ">");
}
}
}
Aggregations