Package org.elasticsearch.search.internal

Examples of org.elasticsearch.search.internal.SearchContext


            cleanContext(context);
        }
    }

    public QuerySearchResult executeQueryPhase(QuerySearchRequest request) throws ElasticSearchException {
        SearchContext context = findContext(request.id());
        contextProcessing(context);
        try {
            context.searcher().dfSource(new CachedDfSource(request.dfs(), context.similarityService().defaultSearchSimilarity()));
        } catch (IOException e) {
            freeContext(context);
            cleanContext(context);
            throw new QueryPhaseExecutionException(context, "Failed to set aggregated df", e);
        }
        try {
            queryPhase.execute(context);
            contextProcessedSuccessfully(context);
            return context.queryResult();
        } catch (RuntimeException e) {
            logger.trace("Query phase failed", e);
            freeContext(context);
            throw e;
        } finally {
View Full Code Here


            cleanContext(context);
        }
    }

    public QueryFetchSearchResult executeFetchPhase(InternalSearchRequest request) throws ElasticSearchException {
        SearchContext context = createContext(request);
        activeContexts.put(context.id(), context);
        contextProcessing(context);
        try {
            queryPhase.execute(context);
            shortcutDocIdsToLoad(context);
            fetchPhase.execute(context);
            if (context.scroll() == null) {
                freeContext(context.id());
            } else {
                contextProcessedSuccessfully(context);
            }
            return new QueryFetchSearchResult(context.queryResult(), context.fetchResult());
        } catch (RuntimeException e) {
            logger.trace("Fetch phase failed", e);
            freeContext(context);
            throw e;
        } finally {
View Full Code Here

            cleanContext(context);
        }
    }

    public QueryFetchSearchResult executeFetchPhase(QuerySearchRequest request) throws ElasticSearchException {
        SearchContext context = findContext(request.id());
        contextProcessing(context);
        try {
            context.searcher().dfSource(new CachedDfSource(request.dfs(), context.similarityService().defaultSearchSimilarity()));
        } catch (IOException e) {
            freeContext(context);
            cleanContext(context);
            throw new QueryPhaseExecutionException(context, "Failed to set aggregated df", e);
        }
        try {
            queryPhase.execute(context);
            shortcutDocIdsToLoad(context);
            fetchPhase.execute(context);
            if (context.scroll() == null) {
                freeContext(request.id());
            } else {
                contextProcessedSuccessfully(context);
            }
            return new QueryFetchSearchResult(context.queryResult(), context.fetchResult());
        } catch (RuntimeException e) {
            logger.trace("Fetch phase failed", e);
            freeContext(context);
            throw e;
        } finally {
View Full Code Here

            cleanContext(context);
        }
    }

    public ScrollQueryFetchSearchResult executeFetchPhase(InternalScrollSearchRequest request) throws ElasticSearchException {
        SearchContext context = findContext(request.id());
        contextProcessing(context);
        try {
            processScroll(request, context);
            queryPhase.execute(context);
            shortcutDocIdsToLoad(context);
            fetchPhase.execute(context);
            if (context.scroll() == null) {
                freeContext(request.id());
            } else {
                contextProcessedSuccessfully(context);
            }
            return new ScrollQueryFetchSearchResult(new QueryFetchSearchResult(context.queryResult(), context.fetchResult()), context.shardTarget());
        } catch (RuntimeException e) {
            logger.trace("Fetch phase failed", e);
            freeContext(context);
            throw e;
        } finally {
View Full Code Here

            cleanContext(context);
        }
    }

    public FetchSearchResult executeFetchPhase(FetchSearchRequest request) throws ElasticSearchException {
        SearchContext context = findContext(request.id());
        contextProcessing(context);
        try {
            context.docIdsToLoad(request.docIds(), 0, request.docIdsSize());
            fetchPhase.execute(context);
            if (context.scroll() == null) {
                freeContext(request.id());
            } else {
                contextProcessedSuccessfully(context);
            }
            return context.fetchResult();
        } catch (RuntimeException e) {
            logger.trace("Fetch phase failed", e);
            freeContext(context);
            throw e;
        } finally {
View Full Code Here

            cleanContext(context);
        }
    }

    private SearchContext findContext(long id) throws SearchContextMissingException {
        SearchContext context = activeContexts.get(id);
        if (context == null) {
            throw new SearchContextMissingException(id);
        }
        SearchContext.setCurrent(context);
        return context;
View Full Code Here

        IndexShard indexShard = indexService.shardSafe(request.shardId());

        SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.index(), request.shardId());

        Engine.Searcher engineSearcher = indexShard.searcher();
        SearchContext context = new SearchContext(idGenerator.incrementAndGet(), shardTarget, request.searchType(), request.numberOfShards(), request.timeout(), request.types(), engineSearcher, indexService, scriptService);
        SearchContext.setCurrent(context);
        try {
            context.scroll(request.scroll());

            parseSource(context, request.source(), request.sourceOffset(), request.sourceLength());
            parseSource(context, request.extraSource(), request.extraSourceOffset(), request.extraSourceLength());

            // if the from and size are still not set, default them
            if (context.from() == -1) {
                context.from(0);
            }
            if (context.size() == -1) {
                context.size(10);
            }

            Filter aliasFilter = indexService.aliasesService().aliasFilter(request.filteringAliases());
            context.aliasFilter(aliasFilter);

            // pre process
            dfsPhase.preProcess(context);
            queryPhase.preProcess(context);
            fetchPhase.preProcess(context);

            // compute the context keep alive
            long keepAlive = defaultKeepAlive;
            if (request.scroll() != null && request.scroll().keepAlive() != null) {
                keepAlive = request.scroll().keepAlive().millis();
            }
            context.keepAlive(keepAlive);
        } catch (RuntimeException e) {
            context.release();
            throw e;
        }

        return context;
    }
View Full Code Here

        return context;
    }

    public void freeContext(long id) {
        SearchContext context = activeContexts.remove(id);
        if (context == null) {
            return;
        }
        freeContext(context);
    }
View Full Code Here

        query.setBoost(boost);
        // wrap the query with type query
        query = new FilteredQuery(query, parseContext.cacheFilter(childDocMapper.typeFilter(), null));

        SearchContext searchContext = SearchContext.current();
        HasChildFilter childFilter = new HasChildFilter(query, scope, childType, parentType, searchContext);
        // we don't need DeletionAwareConstantScore, since we filter deleted parent docs in the filter
        ConstantScoreQuery childQuery = new ConstantScoreQuery(childFilter);
        childQuery.setBoost(boost);
        searchContext.addScopePhase(childFilter);
        return childQuery;
    }
View Full Code Here

        if (ids.size() == 0) {
            throw new QueryParsingException(parseContext.index(), "[ids] query, no ids values provided");
        }

        if (types == null || types.isEmpty()) {
            SearchContext searchContext = SearchContext.current();
            if (searchContext.hasTypes()) {
                types = Arrays.asList(searchContext.types());
            } else {
                types = parseContext.mapperService().types();
            }
        } else if (types.size() == 1 && Iterables.getFirst(types, null).equals("_all")) {
            types = parseContext.mapperService().types();
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.internal.SearchContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.