Java Code Examples for org.elasticsearch.action.search.SearchRequest#extraSource()
The following examples show how to use
org.elasticsearch.action.search.SearchRequest#extraSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CountRequest.java From Elasticsearch with Apache License 2.0 | 6 votes |
public SearchRequest toSearchRequest() { SearchRequest searchRequest = new SearchRequest(indices()); searchRequest.indicesOptions(indicesOptions()); searchRequest.types(types()); searchRequest.routing(routing()); searchRequest.preference(preference()); searchRequest.source(source()); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.size(0); if (minScore() != DEFAULT_MIN_SCORE) { searchSourceBuilder.minScore(minScore()); } if (terminateAfter() != DEFAULT_TERMINATE_AFTER) { searchSourceBuilder.terminateAfter(terminateAfter()); } searchRequest.extraSource(searchSourceBuilder); return searchRequest; }
Example 2
Source File: ShardSearchLocalRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
ShardSearchLocalRequest(SearchRequest searchRequest, ShardRouting shardRouting, int numberOfShards, String[] filteringAliases, long nowInMillis) { this(shardRouting.shardId(), numberOfShards, searchRequest.searchType(), searchRequest.source(), searchRequest.types(), searchRequest.requestCache()); this.extraSource = searchRequest.extraSource(); this.templateSource = searchRequest.templateSource(); this.template = searchRequest.template(); this.scroll = searchRequest.scroll(); this.filteringAliases = filteringAliases; this.nowInMillis = nowInMillis; copyContextAndHeadersFrom(searchRequest); }
Example 3
Source File: IndexShard.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static SearchRequest generateLocalSearchRequest(String source, String indexName, String type) { LocalRestRequest localRestRequest = new LocalRestRequest("/_search", Method.POST); localRestRequest.setContent(source, null); SearchRequest searchRequest = new SearchRequest(); searchRequest.indices(Strings.splitStringByCommaToArray(indexName)); // get the content, and put it in the body // add content/source as template if template flag is set searchRequest.source(localRestRequest.content()); searchRequest.searchType(SearchType.QUERY_AND_FETCH); searchRequest.extraSource(RestSearchAction.parseSearchSource(localRestRequest)); searchRequest.types(Strings.splitStringByCommaToArray(type)); searchRequest.putHeader("search_source", "reindex"); return searchRequest; }
Example 4
Source File: RestSearchAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static void parseSearchRequest(SearchRequest searchRequest, RestRequest request, ParseFieldMatcher parseFieldMatcher, BytesReference bodyContent) { searchRequest.indices(Strings.splitStringByCommaToArray(request.param("index"))); // get the content, and put it in the body // add content/source as template if template flag is set boolean isTemplateRequest = request.path().endsWith("/template"); if (bodyContent == null) { if (RestActions.hasBodyContent(request)) { bodyContent = RestActions.getRestContent(request); } } if (bodyContent != null) { if (isTemplateRequest) { searchRequest.templateSource(bodyContent); } else { searchRequest.source(bodyContent); } } // do not allow 'query_and_fetch' or 'dfs_query_and_fetch' search types // from the REST layer. these modes are an internal optimization and should // not be specified explicitly by the user. String searchType = request.param("search_type"); if (SearchType.fromString(searchType, parseFieldMatcher).equals(SearchType.QUERY_AND_FETCH) || SearchType.fromString(searchType, parseFieldMatcher).equals(SearchType.DFS_QUERY_AND_FETCH)) { throw new IllegalArgumentException("Unsupported search type [" + searchType + "]"); } else { searchRequest.searchType(searchType); } searchRequest.extraSource(parseSearchSource(request)); searchRequest.requestCache(request.paramAsBoolean("request_cache", null)); String scroll = request.param("scroll"); if (scroll != null) { searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll"))); } searchRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); searchRequest.routing(request.param("routing")); searchRequest.preference(request.param("preference")); searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions())); }