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


Java SearchCriteria.isNoFacets方法代码示例

本文整理汇总了Java中org.jai.search.model.SearchCriteria.isNoFacets方法的典型用法代码示例。如果您正苦于以下问题:Java SearchCriteria.isNoFacets方法的具体用法?Java SearchCriteria.isNoFacets怎么用?Java SearchCriteria.isNoFacets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jai.search.model.SearchCriteria的用法示例。


在下文中一共展示了SearchCriteria.isNoFacets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchProducts

import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Override
public ProductSearchResult searchProducts(SearchCriteria searchCriteria)
{
    QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);

    SearchRequestBuilder requestBuilder = getSearchRequestBuilder(searchCriteria.getIndexes(), 
                                                                    searchCriteria.getDocumentTypes(), 
                                                                    searchCriteria.getFrom(), 
                                                                    searchCriteria.getSize());
    requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
    
    if(searchCriteria.isRescoreOnSoldOut())
    {
        Rescorer rescorer = RescoreBuilder.queryRescorer(QueryBuilders.termQuery(SearchDocumentFieldName.SOLD_OUT.getFieldName(), false))
                                           .setQueryWeight(1.0f) //default
                                           .setRescoreQueryWeight(1.5f)
                                           ;
        requestBuilder.setRescorer(rescorer);
    }
    
    if (searchCriteria.hasFilters())
    {
        AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
        requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder, andFilterBuilder));
    } else
    {
        requestBuilder.setQuery(queryBuilder);
    }

    if (!searchCriteria.isNoFacets() && searchCriteria.getFacets().size() > 0)
    {
        addFacets(searchCriteria, requestBuilder);
    }

  //Add sorting
    if(searchCriteria.getSortOrder() !=null)
    {
        //First on given field
        requestBuilder.addSort(SortBuilders.fieldSort(SearchDocumentFieldName.AVAILABLE_DATE.getFieldName()).order(searchCriteria.getSortOrder()).missing("_last"));
        //then on score based
        requestBuilder.addSort(SortBuilders.scoreSort());
    }

    logger.debug("Executing following search request:" + requestBuilder.internalBuilder().toString());
    
    SearchResponse searchResponse = requestBuilder.execute().actionGet();
    
    printSearchResponseForDebug(searchResponse);
    
    return getProductSearchResults(searchResponse);
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:52,代码来源:ProductQueryServiceImpl.java

示例2: searchProducts

import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Override
public ProductSearchResult searchProducts(final SearchCriteria searchCriteria)
{
    final QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);
    final SearchRequestBuilder requestBuilder = getSearchRequestBuilder(searchCriteria.getIndexes(), searchCriteria.getDocumentTypes(),
            searchCriteria.getFrom(), searchCriteria.getSize());
    requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
    if (searchCriteria.isRescoreOnSoldOut())
    {
        final Rescorer rescorer = RescoreBuilder
                .queryRescorer(QueryBuilders.termQuery(SearchDocumentFieldName.SOLD_OUT.getFieldName(), false)).setQueryWeight(1.0f) // default
                .setRescoreQueryWeight(1.5f);
        requestBuilder.setRescorer(rescorer);
    }
    if (searchCriteria.hasFilters())
    {
        final AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
        requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder, andFilterBuilder));
    }
    else
    {
        requestBuilder.setQuery(queryBuilder);
    }
    if (!searchCriteria.isNoFacets() && searchCriteria.getFacets().size() > 0)
    {
        addFacets(searchCriteria, requestBuilder);
    }
    // Add sorting
    if (searchCriteria.getSortOrder() != null)
    {
        // First on given field
        requestBuilder.addSort(SortBuilders.fieldSort(SearchDocumentFieldName.AVAILABLE_DATE.getFieldName())
                .order(searchCriteria.getSortOrder()).missing("_last"));
        // then on score based
        requestBuilder.addSort(SortBuilders.scoreSort());
    }
    logger.debug("Executing following search request:" + requestBuilder.internalBuilder().toString());
    final SearchResponse searchResponse = requestBuilder.execute().actionGet();
    printSearchResponseForDebug(searchResponse);
    return getProductSearchResults(searchResponse);
}
 
开发者ID:jaibeermalik,项目名称:elasticsearch-akka,代码行数:42,代码来源:ProductQueryServiceImpl.java

示例3: searchProducts

import org.jai.search.model.SearchCriteria; //导入方法依赖的package包/类
@Override
public ProductSearchResult searchProducts(
		final SearchCriteria searchCriteria) {
	final QueryBuilder queryBuilder = getQueryBuilder(searchCriteria);
	final SearchRequestBuilder requestBuilder = getSearchRequestBuilder(
			searchCriteria.getIndexes(), searchCriteria.getDocumentTypes(),
			searchCriteria.getFrom(), searchCriteria.getSize());
	requestBuilder.addFields(SearchDocumentFieldName.productQueryFields);
	if (searchCriteria.isRescoreOnSoldOut()) {
		final Rescorer rescorer = RescoreBuilder
				.queryRescorer(
						QueryBuilders.termQuery(
								SearchDocumentFieldName.SOLD_OUT
										.getFieldName(), false))
				.setQueryWeight(1.0f) // default
				.setRescoreQueryWeight(1.5f);
		requestBuilder.setRescorer(rescorer);
	}
	if (searchCriteria.hasFilters()) {
		final AndFilterBuilder andFilterBuilder = getFilterBuilderForSearchCriteria(searchCriteria);
		requestBuilder.setQuery(QueryBuilders.filteredQuery(queryBuilder,
				andFilterBuilder));
	} else {
		requestBuilder.setQuery(queryBuilder);
	}
	if (!searchCriteria.isNoFacets()
			&& searchCriteria.getFacets().size() > 0) {
		addFacets(searchCriteria, requestBuilder);
	}
	// Add sorting
	if (searchCriteria.getSortOrder() != null) {
		// First on given field
		requestBuilder.addSort(SortBuilders
				.fieldSort(
						SearchDocumentFieldName.AVAILABLE_DATE
								.getFieldName())
				.order(searchCriteria.getSortOrder()).missing("_last"));
		// then on score based
		requestBuilder.addSort(SortBuilders.scoreSort());
	}
	logger.debug("Executing following search request:"
			+ requestBuilder.internalBuilder().toString());
	final SearchResponse searchResponse = requestBuilder.execute()
			.actionGet();
	printSearchResponseForDebug(searchResponse);
	return getProductSearchResults(searchResponse);
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:48,代码来源:ProductQueryServiceImpl.java


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