本文整理匯總了Java中org.jai.search.model.FacetResult類的典型用法代碼示例。如果您正苦於以下問題:Java FacetResult類的具體用法?Java FacetResult怎麽用?Java FacetResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FacetResult類屬於org.jai.search.model包,在下文中一共展示了FacetResult類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRandomFilters
import org.jai.search.model.FacetResult; //導入依賴的package包/類
private Map<String, Set<String>> getRandomFilters(
final ProductSearchResult searchProducts) {
final Map<String, Set<String>> filters = new LinkedHashMap<String, Set<String>>();
// Add once
final FacetResult facetResult = searchProducts.getFacets().get(
new Random().nextInt(6));
FacetResultEntry facetResultEntry = null;
if (facetResult.getFacetResultEntries().size() > 1) {
facetResultEntry = facetResult.getFacetResultEntries().get(
new Random().nextInt(facetResult.getFacetResultEntries()
.size() - 1));
} else {
facetResultEntry = facetResult.getFacetResultEntries().get(0);
}
final Set<String> list = new HashSet<String>();
list.add(facetResultEntry.getTerm());
filters.put(facetResult.getCode(), list);
// try randomly again
secondfilter: if (new Random().nextBoolean()) {
final FacetResult facetResult2 = searchProducts.getFacets().get(
new Random().nextInt(6));
FacetResultEntry facetResultEntry2 = null;
// if no entries, break the label.
if (facetResult2.getFacetResultEntries().size() == 0) {
break secondfilter;
}
if (facetResult2.getFacetResultEntries().size() > 1) {
facetResultEntry2 = facetResult2.getFacetResultEntries().get(
new Random().nextInt(facetResult2
.getFacetResultEntries().size() - 1));
} else {
facetResultEntry2 = facetResult2.getFacetResultEntries().get(0);
}
final Set<String> list2 = new HashSet<String>();
list2.add(facetResultEntry2.getTerm());
final String key2 = facetResult2.getCode();
if (filters.containsKey(key2)) {
filters.get(key2).add(facetResultEntry2.getTerm());
} else {
filters.put(key2, list2);
}
}
return filters;
}