Lucene.Net.Search.TermQuery.CreateWeight C# (CSharp) Method

CreateWeight() public method

public CreateWeight ( IndexSearcher searcher ) : Weight
searcher IndexSearcher
return Weight
        public override Weight CreateWeight(IndexSearcher searcher)
        {
            IndexReaderContext context = searcher.TopReaderContext;
            TermContext termState;
            if (PerReaderTermState == null || PerReaderTermState.TopReaderContext != context)
            {
                // make TermQuery single-pass if we don't have a PRTS or if the context differs!
                termState = TermContext.Build(context, Term_Renamed);
            }
            else
            {
                // PRTS was pre-build for this IS
                termState = this.PerReaderTermState;
            }

            // we must not ignore the given docFreq - if set use the given value (lie)
            if (DocFreq != -1)
            {
                termState.DocFreq = DocFreq;
            }

            return new TermWeight(this, searcher, termState);
        }

Usage Example

Example #1
0
 public override Weight CreateWeight(Searcher searcher)
 {
     if (terms.Count == 1)
     {
         // optimize one-term case
         Term  term      = (Term)terms[0];
         Query termQuery = new TermQuery(term);
         termQuery.SetBoost(GetBoost());
         return(termQuery.CreateWeight(searcher));
     }
     return(new PhraseWeight(this, searcher));
 }
All Usage Examples Of Lucene.Net.Search.TermQuery::CreateWeight