@Override public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { return query.createWeight(searcher, needsScores, BoostQuery.this.boost * boost); }
@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
/** * 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; }
@Override public DoubleValuesSource rewrite(IndexSearcher searcher) throws IOException { return new WeightDoubleValuesSource(searcher.rewrite(query).createWeight(searcher, true, 1f)); }
@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); } }
final Weight weight = searcher.rewrite(q).createWeight(searcher, needsScores, score()); return new WeightOrDocIdSet(weight); } else {
final Weight weight = searcher.rewrite(q).createWeight(searcher, needsScores, score()); return new WeightOrDocIdSet(weight);
@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); }
final Weight weight = rewritten_q.createWeight(searcher, false);
final Weight nestedWeight = filter.createWeight(sc.searcher(), false, 1f); Scorer scorer = nestedWeight.scorer(context); if (scorer == null) {
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); }
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)); }
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)); }
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)); } }
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); }
@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); }
/** * {@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); }
@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); }
/** 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; }
/** 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; }