本文整理汇总了Java中com.liferay.portal.kernel.search.facet.collector.FacetCollector类的典型用法代码示例。如果您正苦于以下问题:Java FacetCollector类的具体用法?Java FacetCollector怎么用?Java FacetCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FacetCollector类属于com.liferay.portal.kernel.search.facet.collector包,在下文中一共展示了FacetCollector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateValues
import com.liferay.portal.kernel.search.facet.collector.FacetCollector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public JSONArray translateValues(
QueryParams queryParams, FacetCollector facetCollector,
JSONObject configuration)
throws Exception {
JSONArray facetArray = JSONFactoryUtil.createJSONArray();
List<TermCollector> termCollectors = facetCollector.getTermCollectors();
for (TermCollector tc : termCollectors) {
JSONObject item = parseDocumentTypeData(tc, queryParams.getLocale());
if (item != null) {
facetArray.put(item);
}
}
return facetArray;
}
示例2: translateValues
import com.liferay.portal.kernel.search.facet.collector.FacetCollector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public JSONArray translateValues(
QueryParams queryParams, FacetCollector facetCollector,
JSONObject configuration)
throws Exception {
JSONArray facetArray = JSONFactoryUtil.createJSONArray();
List<TermCollector> termCollectors = facetCollector.getTermCollectors();
for (TermCollector tc : termCollectors) {
JSONObject item = parseStructureData(tc, queryParams.getLocale());
facetArray.put(item);
}
return facetArray;
}
示例3: translateValues
import com.liferay.portal.kernel.search.facet.collector.FacetCollector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public JSONArray translateValues(
QueryParams queryParams, FacetCollector facetCollector,
JSONObject configuration)
throws Exception {
Map<String, Integer> termMap = new HashMap<String, Integer>();
JSONArray aggregations = configuration.getJSONArray("aggregations");
List<TermCollector> termCollectors = facetCollector.getTermCollectors();
// First aggregate frequency counts
boolean mappingFound = false;
for (TermCollector tc : termCollectors) {
mappingFound = false;
for (int i = 0; i < aggregations.length(); i++) {
JSONObject aggregation = aggregations.getJSONObject(i);
String key = aggregation.getString("key");
String[] values = aggregation.getString("values").split(",");
for (int j = 0; j < values.length; j++) {
if (values[j].equals(tc.getTerm())) {
if (termMap.get(key) != null) {
int newValue = termMap.get(key) + tc.getFrequency();
termMap.put(key, newValue);
}
else {
termMap.put(key, tc.getFrequency());;
}
mappingFound = true;
continue;
}
}
}
if (!mappingFound) {
termMap.put(tc.getTerm(), tc.getFrequency());;
}
}
// Then build JSON array
JSONArray facetArray = JSONFactoryUtil.createJSONArray();
for (Entry<String, Integer> entry : termMap.entrySet()) {
JSONObject item = JSONFactoryUtil.createJSONObject();
item.put("frequency", entry.getValue());
item.put("name", entry.getKey());
item.put("term", entry.getKey());
facetArray.put(item);
}
return facetArray;
}
示例4: updateFacetCollectors
import com.liferay.portal.kernel.search.facet.collector.FacetCollector; //导入依赖的package包/类
protected void updateFacetCollectors(
SearchContext searchContext, SearchResponse searchResponse) {
Map<String, Facet> facetsMap = searchContext.getFacets();
for (Facet facet : facetsMap.values()) {
if (facet.isStatic()) {
continue;
}
Aggregations facets = searchResponse.getAggregations();
Aggregation elasticsearchFacet =
facets.get(facet.getFieldName());
FacetCollector facetCollector =
new ElasticsearchFacetFieldCollector(elasticsearchFacet);
facet.setFacetCollector(facetCollector);
}
}
示例5: translateValues
import com.liferay.portal.kernel.search.facet.collector.FacetCollector; //导入依赖的package包/类
/**
* Translate search result values for UI.
*
* @param queryParams
* @param facetCollector
* @param configuration
* @return
* @throws Exception
*/
public JSONArray translateValues(
QueryParams queryParams, FacetCollector facetCollector,
JSONObject configuration)
throws Exception;