本文整理匯總了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);
}