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

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

本文整理了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

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

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

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

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

/**
 * Creates a {@link Weight} for the given query, potentially adding caching
 * if possible and configured.
 * @lucene.experimental
 */
public Weight createWeight(Query query, boolean needsScores, float boost) throws IOException {
 final QueryCache queryCache = this.queryCache;
 Weight weight = query.createWeight(this, needsScores, boost);
 if (needsScores == false && queryCache != null) {
  weight = queryCache.doCache(weight, queryCachingPolicy);
 }
 return weight;
}

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

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

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

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

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

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

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

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

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

@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
  if (needsScores == false && minScore == null) {
    return subQuery.createWeight(searcher, needsScores, boost);
  }
  boolean subQueryNeedsScores = combineFunction != CombineFunction.REPLACE;
  Weight[] filterWeights = new Weight[functions.length];
  for (int i = 0; i < functions.length; ++i) {
    subQueryNeedsScores |= functions[i].needsScores();
    if (functions[i] instanceof FilterScoreFunction) {
      Query filter = ((FilterScoreFunction) functions[i]).filter;
      filterWeights[i] = searcher.createNormalizedWeight(filter, false);
    }
  }
  Weight subQueryWeight = subQuery.createWeight(searcher, subQueryNeedsScores, boost);
  return new CustomBoostFactorWeight(this, subQueryWeight, filterWeights, subQueryNeedsScores);
}

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

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

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

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

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

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

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

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

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

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

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

public BooleanWeight(Searcher searcher)
 throws IOException {
 this.similarity = getSimilarity(searcher);
 for (int i = 0 ; i < clauses.size(); i++) {
  BooleanClause c = (BooleanClause)clauses.get(i);
  weights.add(c.getQuery().createWeight(searcher));
 }
}

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

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

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

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

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

/**
 * {@inheritDoc}
 */
@Override
public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException
{
  Scorer parentScorer = parentQuery.createWeight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
  return new ChildTraversingQueryNodeScorer(searcher, parentScorer, reader, scoreDocsInOrder, topScorer);
}

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

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

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

/** Expert: Constructs and initializes a Weight for a top-level query. */
public Weight weight(Searcher searcher)
 throws IOException {
 Query query = searcher.rewrite(this);
 Weight weight = query.createWeight(searcher);
 float sum = weight.sumOfSquaredWeights();
 float norm = getSimilarity(searcher).queryNorm(sum);
 weight.normalize(norm);
 return weight;
}

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

/** Expert: Constructs an initializes a Weight for a top-level query. */
public Weight weight(Searcher searcher)
 throws IOException {
 Query query = searcher.rewrite(this);
 Weight weight = query.createWeight(searcher);
 float sum = weight.sumOfSquaredWeights();
 float norm = getSimilarity(searcher).queryNorm(sum);
 weight.normalize(norm);
 return weight;
}

相关文章