}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static List<FacetHandler<?>> buildFieldConf() {
List<FacetHandler<?>> facetHandlers = new ArrayList<FacetHandler<?>>();
facetHandlers.add(new SimpleFacetHandler("id"));
SimpleFacetHandler colorHandler = new SimpleFacetHandler("color");
colorHandler.setTermCountSize(TermCountSize.small);
facetHandlers.add(colorHandler);
SimpleFacetHandler shapeHandler = new SimpleFacetHandler("shape");
shapeHandler.setTermCountSize(TermCountSize.medium);
facetHandlers.add(new SimpleFacetHandler("shape"));
facetHandlers.add(new RangeFacetHandler("size", Arrays.asList(new String[] { "[* TO 4]",
"[5 TO 8]", "[9 TO *]" })));
String[] ranges = new String[] { "[000000 TO 000005]", "[000006 TO 000010]",
"[000011 TO 000020]" };
facetHandlers.add(new RangeFacetHandler("numendorsers", new PredefinedTermListFactory(
Integer.class, "000000"), Arrays.asList(ranges)));
PredefinedTermListFactory numTermFactory = new PredefinedTermListFactory(Integer.class, "0000");
facetHandlers.add(new PathFacetHandler("location"));
PathFacetHandler pathHandler = new PathFacetHandler("path");
pathHandler.setSeparator("-");
facetHandlers.add(pathHandler);
PathFacetHandler multipathHandler = new PathFacetHandler("multipath", true);
multipathHandler.setSeparator("-");
facetHandlers.add(multipathHandler);
facetHandlers.add(new SimpleFacetHandler("number", numTermFactory));
facetHandlers.add(new VirtualSimpleFacetHandler("virtual", numTermFactory,
new FacetDataFetcher() {
@Override
public Object fetch(BoboSegmentReader reader, int doc) {
FacetDataCache sourceCache = (FacetDataCache) reader.getFacetData("number");
if (sourceCache == null) return null;
return sourceCache.valArray.getRawValue(sourceCache.orderArray.get(doc));
}
@Override
public void cleanup(BoboSegmentReader reader) {
// do nothing here.
}
}, new HashSet<String>(Arrays.asList(new String[] { "number" }))));
facetHandlers.add(new SimpleFacetHandler("testStored"));
facetHandlers.add(new SimpleFacetHandler("name"));
facetHandlers.add(new RangeFacetHandler("date", new PredefinedTermListFactory(Date.class,
"yyyy/MM/dd"), Arrays.asList(new String[] { "[2000/01/01 TO 2003/05/05]",
"[2003/05/06 TO 2005/04/04]" })));
facetHandlers.add(new SimpleFacetHandler("char", (TermListFactory) null));
facetHandlers.add(new MultiValueFacetHandler("tag", (String) null, (TermListFactory) null,
tagSizePayloadTerm));
facetHandlers.add(new MultiValueFacetHandler("multinum", new PredefinedTermListFactory(
Integer.class, "000")));
facetHandlers.add(new MultiValueFacetHandler("diffname", "multinum",
new PredefinedTermListFactory(Integer.class, "000")));
facetHandlers.add(new MultiValueWithWeightFacetHandler("multiwithweight"));
facetHandlers.add(new CompactMultiValueFacetHandler("compactnum",
new PredefinedTermListFactory(Integer.class, "000")));
facetHandlers.add(new SimpleFacetHandler("storenum", new PredefinedTermListFactory(Long.class,
null)));
/*
* New FacetHandler for geographic locations. Depends on two RangeFacetHandlers on latitude and
* longitude
*/