當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchContext.searcher方法代碼示例

本文整理匯總了Java中org.elasticsearch.search.internal.SearchContext.searcher方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchContext.searcher方法的具體用法?Java SearchContext.searcher怎麽用?Java SearchContext.searcher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.search.internal.SearchContext的用法示例。


在下文中一共展示了SearchContext.searcher方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SignificantTermsAggregatorFactory

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
public SignificantTermsAggregatorFactory(String name, ValuesSourceConfig<ValuesSource> config, IncludeExclude includeExclude,
        String executionHint, QueryBuilder filterBuilder, TermsAggregator.BucketCountThresholds bucketCountThresholds,
        SignificanceHeuristic significanceHeuristic, SearchContext context, AggregatorFactory<?> parent,
        AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
    super(name, config, context, parent, subFactoriesBuilder, metaData);
    this.includeExclude = includeExclude;
    this.executionHint = executionHint;
    this.filter = filterBuilder == null
            ? null
            : filterBuilder.toQuery(context.getQueryShardContext());
    IndexSearcher searcher = context.searcher();
    this.supersetNumDocs = filter == null
            // Important - need to use the doc count that includes deleted docs
            // or we have this issue: https://github.com/elastic/elasticsearch/issues/7951
            ? searcher.getIndexReader().maxDoc()
            : searcher.count(filter);
    this.bucketCountThresholds = bucketCountThresholds;
    this.significanceHeuristic = significanceHeuristic;
    setFieldInfo(context);

}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:SignificantTermsAggregatorFactory.java

示例2: FiltersAggregatorFactory

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
public FiltersAggregatorFactory(String name, List<KeyedFilter> filters, boolean keyed, boolean otherBucket,
        String otherBucketKey, SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories,
        Map<String, Object> metaData) throws IOException {
    super(name, context, parent, subFactories, metaData);
    this.keyed = keyed;
    this.otherBucket = otherBucket;
    this.otherBucketKey = otherBucketKey;
    IndexSearcher contextSearcher = context.searcher();
    weights = new Weight[filters.size()];
    keys = new String[filters.size()];
    for (int i = 0; i < filters.size(); ++i) {
        KeyedFilter keyedFilter = filters.get(i);
        this.keys[i] = keyedFilter.key();
        Query filter = keyedFilter.filter().toFilter(context.getQueryShardContext());
        this.weights[i] = contextSearcher.createNormalizedWeight(filter, false);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:FiltersAggregatorFactory.java

示例3: explain

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
@Override
public Explanation explain(int topLevelDocId, SearchContext context, RescoreSearchContext rescoreContext,
                           Explanation sourceExplanation) throws IOException {
    QueryRescoreContext rescore = (QueryRescoreContext) rescoreContext;
    ContextIndexSearcher searcher = context.searcher();
    if (sourceExplanation == null) {
        // this should not happen but just in case
        return Explanation.noMatch("nothing matched");
    }
    // TODO: this isn't right?  I.e., we are incorrectly pretending all first pass hits were rescored?  If the requested docID was
    // beyond the top rescoreContext.window() in the first pass hits, we don't rescore it now?
    Explanation rescoreExplain = searcher.explain(rescore.query(), topLevelDocId);
    float primaryWeight = rescore.queryWeight();

    Explanation prim;
    if (sourceExplanation.isMatch()) {
        prim = Explanation.match(
                sourceExplanation.getValue() * primaryWeight,
                "product of:", sourceExplanation, Explanation.match(primaryWeight, "primaryWeight"));
    } else {
        prim = Explanation.noMatch("First pass did not match", sourceExplanation);
    }

    // NOTE: we don't use Lucene's Rescorer.explain because we want to insert our own description with which ScoreMode was used.  Maybe
    // we should add QueryRescorer.explainCombine to Lucene?
    if (rescoreExplain != null && rescoreExplain.isMatch()) {
        float secondaryWeight = rescore.rescoreQueryWeight();
        Explanation sec = Explanation.match(
                rescoreExplain.getValue() * secondaryWeight,
                "product of:",
                rescoreExplain, Explanation.match(secondaryWeight, "secondaryWeight"));
        QueryRescoreMode scoreMode = rescore.scoreMode();
        return Explanation.match(
                scoreMode.combine(prim.getValue(), sec.getValue()),
                scoreMode + " of:",
                prim, sec);
    } else {
        return prim;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:41,代碼來源:QueryRescorer.java

示例4: AdjacencyMatrixAggregatorFactory

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
public AdjacencyMatrixAggregatorFactory(String name, List<KeyedFilter> filters, String separator, 
        SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories, 
        Map<String, Object> metaData) throws IOException {
    super(name, context, parent, subFactories, metaData);
    IndexSearcher contextSearcher = context.searcher();
    this.separator = separator;
    weights = new Weight[filters.size()];
    keys = new String[filters.size()];
    for (int i = 0; i < filters.size(); ++i) {
        KeyedFilter keyedFilter = filters.get(i);
        this.keys[i] = keyedFilter.key();
        Query filter = keyedFilter.filter().toFilter(context.getQueryShardContext());
        this.weights[i] = contextSearcher.createNormalizedWeight(filter, false);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,代碼來源:AdjacencyMatrixAggregatorFactory.java

示例5: FilterAggregatorFactory

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
public FilterAggregatorFactory(String name, QueryBuilder filterBuilder, SearchContext context,
        AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
    super(name, context, parent, subFactoriesBuilder, metaData);
    IndexSearcher contextSearcher = context.searcher();
    Query filter = filterBuilder.toQuery(context.getQueryShardContext());
    weight = contextSearcher.createNormalizedWeight(filter, false);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,代碼來源:FilterAggregatorFactory.java

示例6: OrderedDocCollector

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
public OrderedDocCollector(SearchContext searchContext,
                           boolean doDocsScores,
                           int batchSize,
                           CollectorContext collectorContext,
                           OrderBy orderBy,
                           Sort sort,
                           List<Input<?>> inputs,
                           Collection<LuceneCollectorExpression<?>> expressions) {
    this.searchContext = searchContext;
    this.shardId = searchContext.indexShard().shardId();
    this.doDocsScores = doDocsScores;
    this.batchSize = batchSize;
    this.orderBy = orderBy;
    searcher = searchContext.searcher();
    this.collectorContext = collectorContext;
    this.sort = sort;
    this.scorer = new DummyScorer();
    this.expressions = expressions;
    this.rowFunction = new ScoreDocRowFunction(
            searcher.getIndexReader(),
            inputs,
            expressions,
            scorer
    );
    empty = new KeyIterable<>(shardId, Collections.<Row>emptyList());
    missingValues = new Object[orderBy.orderBySymbols().size()];
    for (int i = 0; i < orderBy.orderBySymbols().size(); i++) {
        missingValues[i] = LuceneMissingValue.missingValue(orderBy, i);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:31,代碼來源:OrderedDocCollector.java

示例7: explain

import org.elasticsearch.search.internal.SearchContext; //導入方法依賴的package包/類
@Override
public Explanation explain(int topLevelDocId, SearchContext context, RescoreSearchContext rescoreContext,
                           Explanation sourceExplanation) throws IOException {
    QueryRescoreContext rescore = (QueryRescoreContext) rescoreContext;
    ContextIndexSearcher searcher = context.searcher();
    if (sourceExplanation == null) {
        // this should not happen but just in case
        return Explanation.noMatch("nothing matched");
    }
    // TODO: this isn't right?  I.e., we are incorrectly pretending all first pass hits were rescored?  If the requested docID was
    // beyond the top rescoreContext.window() in the first pass hits, we don't rescore it now?
    Explanation rescoreExplain = searcher.explain(rescore.query(), topLevelDocId);
    float primaryWeight = rescore.queryWeight();

    Explanation prim;
    if (sourceExplanation.isMatch()) {
        prim = Explanation.match(
                sourceExplanation.getValue() * primaryWeight,
                "product of:", sourceExplanation, Explanation.match(primaryWeight, "primaryWeight"));
    } else {
        prim = Explanation.noMatch("First pass did not match", sourceExplanation);
    }

    // NOTE: we don't use Lucene's Rescorer.explain because we want to insert our own description with which ScoreMode was used.  Maybe
    // we should add QueryRescorer.explainCombine to Lucene?
    if (rescoreExplain != null && rescoreExplain.isMatch()) {
        float secondaryWeight = rescore.rescoreQueryWeight();
        Explanation sec = Explanation.match(
                rescoreExplain.getValue() * secondaryWeight,
                "product of:",
                rescoreExplain, Explanation.match(secondaryWeight, "secondaryWeight"));
        ScoreMode scoreMode = rescore.scoreMode();
        return Explanation.match(
                scoreMode.combine(prim.getValue(), sec.getValue()),
                scoreMode + " of:",
                prim, sec);
    } else {
        return prim;
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:41,代碼來源:QueryRescorer.java


注:本文中的org.elasticsearch.search.internal.SearchContext.searcher方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。