Java Code Examples for org.apache.lucene.index.TermContext#build()
The following examples show how to use
org.apache.lucene.index.TermContext#build() .
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: BlendedTermQuery.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Query rewrite(IndexReader reader) throws IOException { IndexReaderContext context = reader.getContext(); TermContext[] ctx = new TermContext[terms.length]; int[] docFreqs = new int[ctx.length]; for (int i = 0; i < terms.length; i++) { ctx[i] = TermContext.build(context, terms[i]); docFreqs[i] = ctx[i].docFreq(); } final int maxDoc = reader.maxDoc(); blend(ctx, maxDoc, reader); Query query = topLevelQuery(terms, ctx, docFreqs, maxDoc); query.setBoost(getBoost()); return query; }
Example 2
Source File: AbstractAuthorityQueryWeight.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public AbstractAuthorityQueryWeight(SolrIndexSearcher searcher, boolean needsScores, Query query, String authTermName, String authTermText) throws IOException { super(query); this.searcher = searcher; searcher.collectionStatistics(authTermName); final IndexReaderContext context = searcher.getTopReaderContext(); final Term term = new Term(authTermName, authTermText); final TermContext termContext = TermContext.build(context, term); searcher.termStatistics(term, termContext); this.needsScores = needsScores; }
Example 3
Source File: MtasExtendedSpanTermQuery.java From mtas with Apache License 2.0 | 5 votes |
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null) { context = TermContext.build(topContext, localTerm); } else { context = termContext; } return new SpanTermWeight(context, searcher, needsScores ? Collections.singletonMap(localTerm, context) : null, boost); }