org.apache.lucene.search.Query.createWeight()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(245)

本文整理了Java中org.apache.lucene.search.Query.createWeight方法的一些代码示例,展示了Query.createWeight的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.createWeight方法的具体详情如下:
包路径:org.apache.lucene.search.Query
类名称:Query
方法名:createWeight

Query.createWeight介绍

[英]Expert: Constructs an appropriate Weight implementation for this query.

Only implemented by primitive queries, which re-write to themselves.
[中]专家:为此查询构造适当的权重实现。
仅由原语查询实现,原语查询会重新写入自身。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  3. return query.createWeight(searcher, needsScores, BoostQuery.this.boost * boost);
  4. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  3. final Weight indexWeight = indexQuery.createWeight(searcher, needsScores, boost);
  4. final Weight dvWeight = dvQuery.createWeight(searcher, needsScores, boost);
  5. return new Weight(this) {
  6. @Override

代码示例来源:origin: org.apache.lucene/lucene-core

  1. /**
  2. * Creates a {@link Weight} for the given query, potentially adding caching
  3. * if possible and configured.
  4. * @lucene.experimental
  5. */
  6. public Weight createWeight(Query query, boolean needsScores, float boost) throws IOException {
  7. final QueryCache queryCache = this.queryCache;
  8. Weight weight = query.createWeight(this, needsScores, boost);
  9. if (needsScores == false && queryCache != null) {
  10. weight = queryCache.doCache(weight, queryCachingPolicy);
  11. }
  12. return weight;
  13. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. @Override
  2. public DoubleValuesSource rewrite(IndexSearcher searcher) throws IOException {
  3. return new WeightDoubleValuesSource(searcher.rewrite(query).createWeight(searcher, true, 1f));
  4. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  3. if (needsScores) {
  4. return new SynonymWeight(this, searcher, boost);
  5. } else {
  6. // if scores are not needed, let BooleanWeight deal with optimizing that case.
  7. BooleanQuery.Builder bq = new BooleanQuery.Builder();
  8. for (Term term : terms) {
  9. bq.add(new TermQuery(term), BooleanClause.Occur.SHOULD);
  10. }
  11. return searcher.rewrite(bq.build()).createWeight(searcher, needsScores, boost);
  12. }
  13. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. final Weight weight = searcher.rewrite(q).createWeight(searcher, needsScores, score());
  2. return new WeightOrDocIdSet(weight);
  3. } else {

代码示例来源:origin: org.apache.lucene/lucene-core

  1. final Weight weight = searcher.rewrite(q).createWeight(searcher, needsScores, score());
  2. return new WeightOrDocIdSet(weight);

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  3. if (needsScores == false && minScore == null) {
  4. return subQuery.createWeight(searcher, needsScores, boost);
  5. }
  6. boolean subQueryNeedsScores = combineFunction != CombineFunction.REPLACE;
  7. Weight[] filterWeights = new Weight[functions.length];
  8. for (int i = 0; i < functions.length; ++i) {
  9. subQueryNeedsScores |= functions[i].needsScores();
  10. if (functions[i] instanceof FilterScoreFunction) {
  11. Query filter = ((FilterScoreFunction) functions[i]).filter;
  12. filterWeights[i] = searcher.createNormalizedWeight(filter, false);
  13. }
  14. }
  15. Weight subQueryWeight = subQuery.createWeight(searcher, subQueryNeedsScores, boost);
  16. return new CustomBoostFactorWeight(this, subQueryWeight, filterWeights, subQueryNeedsScores);
  17. }

代码示例来源:origin: rnewson/couchdb-lucene

  1. final Weight weight = rewritten_q.createWeight(searcher, false);

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. final Weight nestedWeight = filter.createWeight(sc.searcher(), false, 1f);
  2. Scorer scorer = nestedWeight.scorer(context);
  3. if (scorer == null) {

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

  1. public LuceneQueryHits(IndexReader reader,
  2. IndexSearcher searcher,
  3. Query query)
  4. throws IOException {
  5. this.reader = reader;
  6. // We rely on Scorer#nextDoc() and Scorer#advance(int) so enable
  7. // scoreDocsInOrder
  8. this.scorer = query.createWeight(searcher).scorer(reader, true, false);
  9. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. public DisjunctionMaxWeight(Searcher searcher) throws IOException {
  2. this.similarity = searcher.getSimilarity();
  3. for (int i = 0; i < disjuncts.size(); i++)
  4. weights.add(((Query) disjuncts.get(i)).createWeight(searcher));
  5. }

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

  1. public DisjunctionMaxWeight(Searcher searcher) throws IOException {
  2. this.similarity = searcher.getSimilarity();
  3. for (int i = 0; i < disjuncts.size(); i++)
  4. weights.add(((Query) disjuncts.get(i)).createWeight(searcher));
  5. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. public BooleanWeight(Searcher searcher)
  2. throws IOException {
  3. this.similarity = getSimilarity(searcher);
  4. for (int i = 0 ; i < clauses.size(); i++) {
  5. BooleanClause c = (BooleanClause)clauses.get(i);
  6. weights.add(c.getQuery().createWeight(searcher));
  7. }
  8. }

代码示例来源:origin: lucene/lucene

  1. protected Weight createWeight(Searcher searcher) {
  2. if (terms.size() == 1) { // optimize one-term case
  3. Term term = (Term)terms.elementAt(0);
  4. Query termQuery = new TermQuery(term);
  5. termQuery.setBoost(getBoost());
  6. return termQuery.createWeight(searcher);
  7. }
  8. return new PhraseWeight(searcher);
  9. }

代码示例来源:origin: org.xcmis/xcmis-search-service

  1. @Override
  2. public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
  3. {
  4. Scorer parentScorer = parentQuery.createWeight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
  5. return new DescendantQueryNodeScorer(searcher, parentScorer, reader, scoreDocsInOrder, topScorer);
  6. }

代码示例来源:origin: org.xcmis/xcmis-search-service

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
  6. {
  7. Scorer parentScorer = parentQuery.createWeight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
  8. return new ChildTraversingQueryNodeScorer(searcher, parentScorer, reader, scoreDocsInOrder, topScorer);
  9. }

代码示例来源:origin: org.apache.lucene/lucene-queries

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  3. Weight inner = in.createWeight(searcher, needsScores && source.needsScores(), 1f);
  4. if (needsScores == false)
  5. return inner;
  6. return new FunctionScoreWeight(this, inner, source.rewrite(searcher), boost);
  7. }

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

  1. /** Expert: Constructs and initializes a Weight for a top-level query. */
  2. public Weight weight(Searcher searcher)
  3. throws IOException {
  4. Query query = searcher.rewrite(this);
  5. Weight weight = query.createWeight(searcher);
  6. float sum = weight.sumOfSquaredWeights();
  7. float norm = getSimilarity(searcher).queryNorm(sum);
  8. weight.normalize(norm);
  9. return weight;
  10. }

代码示例来源:origin: lucene/lucene

  1. /** Expert: Constructs an initializes a Weight for a top-level query. */
  2. public Weight weight(Searcher searcher)
  3. throws IOException {
  4. Query query = searcher.rewrite(this);
  5. Weight weight = query.createWeight(searcher);
  6. float sum = weight.sumOfSquaredWeights();
  7. float norm = getSimilarity(searcher).queryNorm(sum);
  8. weight.normalize(norm);
  9. return weight;
  10. }

相关文章