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


Java SearchRequestBuilder.setFetchSource方法代码示例

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


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

示例1: customSearchWithHighlightedSummary

import org.elasticsearch.action.search.SearchRequestBuilder; //导入方法依赖的package包/类
/**
 * Return records for query, and highlight the fragment of content with the ResultHighlightMapper
 *
 * @param pageable
 * @param query
 * @param version
 * @param project
 * @return
 */
@Override
public Page<File> customSearchWithHighlightedSummary(Pageable pageable, String query, List<String> version, List<String> project, List<String> extension) {
    if (StringUtils.isEmpty(query)) {
        log.error("customSearchWithHighlightedSummary return null in case where query = " + query);
        return null;
    }
    NativeSearchQueryBuilder nativeSearchQueryBuilder = Queries.constructSearchQueryBuilder(query);
    NativeSearchQuery nativeSearchQuery = nativeSearchQueryBuilder.build();

    SearchRequestBuilder searchRequestBuilder = constructRequestBuilder(nativeSearchQuery, pageable, version, project, extension);
    searchRequestBuilder.setFetchSource(null, "content");//dont get the content, we have the highlight !

    log.trace("==> Request  ES ==> \n{}", searchRequestBuilder);
    SearchResponse response = searchRequestBuilder.execute().actionGet();
    log.trace("<== Response ES <== \n{}", response);

    SearchHit[] hits = response.getHits().hits();
    ResultHighlightMapper mapper = new ResultHighlightMapper();
    return mapper.mapResults(response, File.class, nativeSearchQuery.getPageable());

}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:31,代码来源:CustomSearchRepositoryImpl.java

示例2: applyEdgeProjection

import org.elasticsearch.action.search.SearchRequestBuilder; //导入方法依赖的package包/类
protected void applyEdgeProjection(SearchRequestBuilder searchRequest, ElasticIntermediateScanPrel scan) {
  boolean edgeProject = PrelUtil.getPlannerSettings(scan.getCluster()).getOptions().getOption(ExecConstants.ELASTIC_RULES_EDGE_PROJECT);
  if(!edgeProject){
    return;
  }


  final String[] includesOrderedByOriginalTable;
  if (scan.getProjectedColumns().isEmpty()) {
    includesOrderedByOriginalTable = new String[0];
  } else
    includesOrderedByOriginalTable =
        scan.getBatchSchema().mask(scan.getProjectedColumns(), false)
          .toCalciteRecordType(scan.getCluster().getTypeFactory()).getFieldNames().toArray(new String[0]);

  // canonicalize includes order so we don't get test variability.
  Arrays.sort(includesOrderedByOriginalTable);
  searchRequest.setFetchSource(includesOrderedByOriginalTable, null);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:ScanBuilder.java


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