br.setFacetSpec("distance", geoSpec);
HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
answer.put(
"distance",
Arrays.asList(new BrowseFacet[] { new BrowseFacet("30,70:5", 2),
new BrowseFacet("60,120:1", 2) }));
doTest(br, 4, answer, new String[] { "1", "3", "4", "5" });
// testing for selection of facet <60,120,1> and verifying that 2 documents match this facet.
BrowseRequest br2 = new BrowseRequest();
br2.setCount(10);
br2.setOffset(0);
BrowseSelection sel2 = new BrowseSelection("distance");
sel2.addValue("60,120:1");
HashMap<String, Float> map = new HashMap<String, Float>();
map.put("0,120:1", 3.0f);
FacetTermQuery geoQ = new FacetTermQuery(sel2, map);
br2.setQuery(geoQ);
doTest(br2, 2, null, new String[] { "1", "5" });
// facet query for color "red" and getting facet counts for the distance facet.
BrowseRequest br3 = new BrowseRequest();
br3.setCount(10);
br3.setOffset(0);
BrowseSelection sel3 = new BrowseSelection("color");
sel3.addValue("red");
HashMap<String, Float> map3 = new HashMap<String, Float>();
map3.put("red", 3.0f);
FacetTermQuery colorQ = new FacetTermQuery(sel3, map3);
br3.setFacetSpec("distance", geoSpec);
geoSpec.setMinHitCount(0);
br3.setQuery(colorQ); // query is color=red
br3.addSelection(sel); // count facets <30,70,5> and <60,120,1>
answer.clear();
answer.put(
"distance",
Arrays.asList(new BrowseFacet[] { new BrowseFacet("30,70:5", 0),
new BrowseFacet("60,120:1", 1) }));
doTest(br3, 1, answer, null);
}