本文整理汇总了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());
}
示例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);
}