当前位置: 首页>>代码示例>>Java>>正文


Java FacetCollector类代码示例

本文整理汇总了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;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:25,代码来源:DocumentTypeFacetTranslator.java

示例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;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:22,代码来源:WebContentStructureFacetTranslator.java

示例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;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:68,代码来源:DocumentExtensionFacetTranslator.java

示例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);
    }

}
 
开发者ID:R-Knowsys,项目名称:elasticray,代码行数:24,代码来源:ElasticsearchIndexSearcher.java

示例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;
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:14,代码来源:FacetTranslator.java


注:本文中的com.liferay.portal.kernel.search.facet.collector.FacetCollector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。