DefaultSearchContext context = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, engineSearcher, indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher, defaultSearchTimeout); SearchContext.setCurrent(context); try { if (request.scroll() != null) { context.scrollContext(new ScrollContext()); context.scrollContext().scroll = request.scroll(); if (context.from() == -1) { context.from(0); if (context.searchType() == SearchType.COUNT) { context.searchType(SearchType.QUERY_THEN_FETCH); context.size(0); } else if (context.size() == -1) { context.size(10); if (context.request().isProfile()) { context.setProfilers(new Profilers(context.searcher())); keepAlive = request.scroll().keepAlive().millis(); context.keepAlive(keepAlive); } catch (Throwable e) { context.close(); throw ExceptionsHelper.convertToRuntime(e);
public void preProcess() { if (scrollContext == null) { long from = from() == -1 ? 0 : from(); long size = size() == -1 ? 10 : size(); long resultWindow = from + size; if (query() == null) { parsedQuery(ParsedQuery.parsedMatchAllQuery()); if (queryBoost() != 1.0f) { parsedQuery(new ParsedQuery(new FunctionScoreQuery(query(), new BoostScoreFunction(queryBoost)), parsedQuery())); filteredQuery(buildFilteredQuery()); try { this.query = searcher().rewrite(this.query); } catch (IOException e) { throw new QueryPhaseExecutionException(this, "Failed to rewrite main query", e);
@Override public SearchLookup lookup() { // TODO: The types should take into account the parsing context in QueryParserContext... if (searchLookup == null) { searchLookup = new SearchLookup(mapperService(), fieldData(), request.types()); } return searchLookup; }
Engine.Searcher searcher = indexShard.acquireSearcher("validate_query"); DefaultSearchContext searchContext = new DefaultSearchContext(0, new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()), null, searcher, indexService, indexShard, try { if (request.source() != null && request.source().length() > 0) { searchContext.parsedQuery(queryParserService.parseQuery(request.source())); searchContext.preProcess(); explanation = getRewrittenQuery(searcher.searcher(), searchContext.query()); } else if (request.explain()) { explanation = searchContext.filteredQuery().query().toString(); error = e.getMessage(); } finally { searchContext.close(); SearchContext.removeCurrent();
private SearchContext createSearchContext(BatchPercolateShardRequest request, IndexService percolateIndexService, IndexShard indexShard, Directory directory) throws IOException { SearchShardTarget searchShardTarget = new SearchShardTarget(clusterService.localNode().id(), request.shardId().getIndex(), request.shardId().id()); return new DefaultSearchContext( 0, new ShardSearchLocalRequest(new ShardId("local_index",0), 0, SearchType.QUERY_AND_FETCH, null, null, false), searchShardTarget, new DocSearcher(new IndexSearcher(DirectoryReader.open(directory))), percolateIndexService, indexShard, scriptService, cacheRecycler, pageCacheRecycler, bigArrays, Counter.newCounter() ); }
shardRequest.filteringAliases()); SearchContext context = new DefaultSearchContext(0, shardSearchRequest, shardTarget, indexShard.acquireSearcher("termsByQuery"), indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
IndexShard indexShard = indexService.shardSafe(request.shardId()); ShardSearchRequest shardSearchRequest = new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()); SearchContext searchContext = new DefaultSearchContext( 0, shardSearchRequest,
SearchContext context = new DefaultSearchContext( 0, new ShardSearchLocalRequest(new String[]{request.type()}, request.nowInMillis, request.filteringAlias()), null, result.searcher(), indexService, indexShard,
SearchContext context = new DefaultSearchContext(0, new ShardSearchLocalRequest(request.types(), request.nowInMillis(), request.filteringAliases()), shardTarget, indexShard.acquireSearcher("exists"), indexService, indexShard,