Java Code Examples for org.apache.lucene.search.ScoreMode#needsScores()
The following examples show how to use
org.apache.lucene.search.ScoreMode#needsScores() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DerivedExpressionQuery.java From elasticsearch-learning-to-rank with Apache License 2.0 | 6 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { if (!scoreMode.needsScores()) { // If scores are not needed simply return a constant score on all docs return new ConstantScoreWeight(this.query, boost) { @Override public boolean isCacheable(LeafReaderContext ctx) { return true; } @Override public Scorer scorer(LeafReaderContext context) throws IOException { return new ConstantScoreScorer(this, score(), scoreMode, DocIdSetIterator.all(context.reader().maxDoc())); } }; } return new FVWeight(this); }
Example 2
Source File: FunctionScoreQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { ScoreMode sm; if (scoreMode.needsScores() && source.needsScores()) { sm = ScoreMode.COMPLETE; } else { sm = ScoreMode.COMPLETE_NO_SCORES; } Weight inner = in.createWeight(searcher, sm, 1f); if (scoreMode.needsScores() == false) return inner; return new FunctionScoreWeight(this, inner, source.rewrite(searcher), boost); }
Example 3
Source File: PayloadScoreQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight innerWeight = wrappedQuery.createWeight(searcher, scoreMode, boost); if (!scoreMode.needsScores()) return innerWeight; return new PayloadSpanWeight(searcher, innerWeight, boost); }
Example 4
Source File: SpanTermQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { final TermStates context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termStates == null || termStates.wasBuiltFor(topContext) == false) { context = TermStates.build(topContext, term, scoreMode.needsScores()); } else { context = termStates; } return new SpanTermWeight(context, searcher, scoreMode.needsScores() ? Collections.singletonMap(term, context) : null, boost); }
Example 5
Source File: SpanContainingQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight bigWeight = big.createWeight(searcher, scoreMode, boost); SpanWeight littleWeight = little.createWeight(searcher, scoreMode, boost); return new SpanContainingWeight(searcher, scoreMode.needsScores() ? getTermStates(bigWeight, littleWeight) : null, bigWeight, littleWeight, boost); }
Example 6
Source File: SpanOrQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { List<SpanWeight> subWeights = new ArrayList<>(clauses.size()); for (SpanQuery q : clauses) { subWeights.add(q.createWeight(searcher, scoreMode, boost)); } return new SpanOrWeight(searcher, scoreMode.needsScores() ? getTermStates(subWeights) : null, subWeights, boost); }
Example 7
Source File: SpanNotQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight includeWeight = include.createWeight(searcher, scoreMode, boost); SpanWeight excludeWeight = exclude.createWeight(searcher, ScoreMode.COMPLETE_NO_SCORES, boost); return new SpanNotWeight(searcher, scoreMode.needsScores() ? getTermStates(includeWeight) : null, includeWeight, excludeWeight, boost); }
Example 8
Source File: SpanNearQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { List<SpanWeight> subWeights = new ArrayList<>(); for (SpanQuery q : clauses) { subWeights.add(q.createWeight(searcher, scoreMode, boost)); } return new SpanNearWeight(subWeights, searcher, scoreMode.needsScores() ? getTermStates(subWeights) : null, boost); }
Example 9
Source File: SpanWithinQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight bigWeight = big.createWeight(searcher, scoreMode, boost); SpanWeight littleWeight = little.createWeight(searcher, scoreMode, boost); return new SpanWithinWeight(searcher, scoreMode.needsScores() ? getTermStates(bigWeight, littleWeight) : null, bigWeight, littleWeight, boost); }
Example 10
Source File: ScriptFeature.java From elasticsearch-learning-to-rank with Apache License 2.0 | 5 votes |
@Override public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { if (!scoreMode.needsScores()) { return new MatchAllDocsQuery().createWeight(searcher, scoreMode, 1F); } return new LtrScriptWeight(this, this.function); }
Example 11
Source File: SpanPayloadCheckQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight matchWeight = match.createWeight(searcher, scoreMode, boost); return new SpanPayloadCheckWeight(searcher, scoreMode.needsScores() ? getTermStates(matchWeight) : null, matchWeight, boost); }
Example 12
Source File: SpanPositionCheckQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { SpanWeight matchWeight = match.createWeight(searcher, scoreMode, boost); return new SpanPositionCheckWeight(matchWeight, searcher, scoreMode.needsScores() ? getTermStates(matchWeight) : null, boost); }