當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。