BrowseSelection sel = new BrowseSelection("correctDistance");
sel.addValue("30,75:100");
sel.addValue("60,120:1");
br.addSelection(sel);
FacetSpec geoSpec = new FacetSpec();
geoSpec.setMinHitCount(0);
geoSpec.setOrderBy(FacetSortSpec.OrderValueAsc);
br.setFacetSpec("correctDistance", geoSpec);
HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
answer.put(
"correctDistance",
Arrays.asList(new BrowseFacet[] { new BrowseFacet("30,75:100", 1),
new BrowseFacet("60,120:1", 2) }));
doTest(br, 3, answer, null);
// 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("correctDistance");
sel2.addValue("60,120:1");
HashMap<String, Float> map = new HashMap<String, Float>();
map.put("60,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("correctDistance", geoSpec);
geoSpec.setMinHitCount(1);
br3.setQuery(colorQ); // query is color=red
br3.addSelection(sel); // count facets <30,70,5> and <60,120,1>
answer.clear();
answer.put("correctDistance",
Arrays.asList(new BrowseFacet[] { new BrowseFacet("60,120:1", 1) }));