Search in sources :

Example 1 with FetchSourceSubPhase

use of org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase in project elasticsearch by elastic.

the class AggregatorTestCase method createSearchContext.

protected SearchContext createSearchContext(IndexSearcher indexSearcher, IndexSettings indexSettings) {
    Engine.Searcher searcher = new Engine.Searcher("aggregator_test", indexSearcher);
    QueryCache queryCache = new DisabledQueryCache(indexSettings);
    QueryCachingPolicy queryCachingPolicy = new QueryCachingPolicy() {

        @Override
        public void onUse(Query query) {
        }

        @Override
        public boolean shouldCache(Query query) throws IOException {
            // never cache a query
            return false;
        }
    };
    ContextIndexSearcher contextIndexSearcher = new ContextIndexSearcher(searcher, queryCache, queryCachingPolicy);
    SearchContext searchContext = mock(SearchContext.class);
    when(searchContext.numberOfShards()).thenReturn(1);
    when(searchContext.searcher()).thenReturn(contextIndexSearcher);
    when(searchContext.fetchPhase()).thenReturn(new FetchPhase(Arrays.asList(new FetchSourceSubPhase(), new DocValueFieldsFetchSubPhase())));
    doAnswer(invocation -> {
        releasables.add((Releasable) invocation.getArguments()[0]);
        return null;
    }).when(searchContext).addReleasable(anyObject(), anyObject());
    return searchContext;
}
Also used : QueryCachingPolicy(org.apache.lucene.search.QueryCachingPolicy) DisabledQueryCache(org.elasticsearch.index.cache.query.DisabledQueryCache) QueryCache(org.apache.lucene.search.QueryCache) Query(org.apache.lucene.search.Query) ContextIndexSearcher(org.elasticsearch.search.internal.ContextIndexSearcher) IndexSearcher(org.apache.lucene.search.IndexSearcher) FetchPhase(org.elasticsearch.search.fetch.FetchPhase) ContextIndexSearcher(org.elasticsearch.search.internal.ContextIndexSearcher) SearchContext(org.elasticsearch.search.internal.SearchContext) Engine(org.elasticsearch.index.engine.Engine) DisabledQueryCache(org.elasticsearch.index.cache.query.DisabledQueryCache) FetchSourceSubPhase(org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase) DocValueFieldsFetchSubPhase(org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase)

Example 2 with FetchSourceSubPhase

use of org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase in project elasticsearch by elastic.

the class SearchModule method registerFetchSubPhases.

private void registerFetchSubPhases(List<SearchPlugin> plugins) {
    registerFetchSubPhase(new ExplainFetchSubPhase());
    registerFetchSubPhase(new DocValueFieldsFetchSubPhase());
    registerFetchSubPhase(new ScriptFieldsFetchSubPhase());
    registerFetchSubPhase(new FetchSourceSubPhase());
    registerFetchSubPhase(new VersionFetchSubPhase());
    registerFetchSubPhase(new MatchedQueriesFetchSubPhase());
    registerFetchSubPhase(new HighlightPhase(settings, highlighters));
    registerFetchSubPhase(new ParentFieldSubFetchPhase());
    FetchPhaseConstructionContext context = new FetchPhaseConstructionContext(highlighters);
    registerFromPlugin(plugins, p -> p.getFetchSubPhases(context), this::registerFetchSubPhase);
}
Also used : ScriptFieldsFetchSubPhase(org.elasticsearch.search.fetch.subphase.ScriptFieldsFetchSubPhase) VersionFetchSubPhase(org.elasticsearch.search.fetch.subphase.VersionFetchSubPhase) MatchedQueriesFetchSubPhase(org.elasticsearch.search.fetch.subphase.MatchedQueriesFetchSubPhase) FetchPhaseConstructionContext(org.elasticsearch.plugins.SearchPlugin.FetchPhaseConstructionContext) ExplainFetchSubPhase(org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase) ParentFieldSubFetchPhase(org.elasticsearch.search.fetch.subphase.ParentFieldSubFetchPhase) DocValueFieldsFetchSubPhase(org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase) FetchSourceSubPhase(org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase) HighlightPhase(org.elasticsearch.search.fetch.subphase.highlight.HighlightPhase)

Aggregations

DocValueFieldsFetchSubPhase (org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase)2 FetchSourceSubPhase (org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 Query (org.apache.lucene.search.Query)1 QueryCache (org.apache.lucene.search.QueryCache)1 QueryCachingPolicy (org.apache.lucene.search.QueryCachingPolicy)1 DisabledQueryCache (org.elasticsearch.index.cache.query.DisabledQueryCache)1 Engine (org.elasticsearch.index.engine.Engine)1 FetchPhaseConstructionContext (org.elasticsearch.plugins.SearchPlugin.FetchPhaseConstructionContext)1 FetchPhase (org.elasticsearch.search.fetch.FetchPhase)1 ExplainFetchSubPhase (org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase)1 MatchedQueriesFetchSubPhase (org.elasticsearch.search.fetch.subphase.MatchedQueriesFetchSubPhase)1 ParentFieldSubFetchPhase (org.elasticsearch.search.fetch.subphase.ParentFieldSubFetchPhase)1 ScriptFieldsFetchSubPhase (org.elasticsearch.search.fetch.subphase.ScriptFieldsFetchSubPhase)1 VersionFetchSubPhase (org.elasticsearch.search.fetch.subphase.VersionFetchSubPhase)1 HighlightPhase (org.elasticsearch.search.fetch.subphase.highlight.HighlightPhase)1 ContextIndexSearcher (org.elasticsearch.search.internal.ContextIndexSearcher)1 SearchContext (org.elasticsearch.search.internal.SearchContext)1