public MultiPhraseWeight(MultiPhraseQuery outerInstance, IndexSearcher searcher) { this.outerInstance = outerInstance; this.similarity = searcher.Similarity; IndexReaderContext context = searcher.TopReaderContext; // compute idf var allTermStats = new List <TermStatistics>(); foreach (Term[] terms in outerInstance.termArrays) { foreach (Term term in terms) { TermContext termContext; termContexts.TryGetValue(term, out termContext); if (termContext == null) { termContext = TermContext.Build(context, term); termContexts[term] = termContext; } allTermStats.Add(searcher.TermStatistics(term, termContext)); } } stats = similarity.ComputeWeight(outerInstance.Boost, searcher.CollectionStatistics(outerInstance.field), allTermStats.ToArray()); }
public PhraseWeight(PhraseQuery outerInstance, IndexSearcher searcher) { this.outerInstance = outerInstance; this.similarity = searcher.Similarity; IndexReaderContext context = searcher.TopReaderContext; states = new TermContext[outerInstance.terms.Count]; TermStatistics[] termStats = new TermStatistics[outerInstance.terms.Count]; for (int i = 0; i < outerInstance.terms.Count; i++) { Term term = outerInstance.terms[i]; states[i] = TermContext.Build(context, term); termStats[i] = searcher.TermStatistics(term, states[i]); } stats = similarity.ComputeWeight(outerInstance.Boost, searcher.CollectionStatistics(outerInstance.field), termStats); }
public TermWeight(TermQuery outerInstance, IndexSearcher searcher, TermContext termStates) { this.outerInstance = outerInstance; if (Debugging.AssertsEnabled) { Debugging.Assert(termStates != null, "TermContext must not be null"); } this.termStates = termStates; this.similarity = searcher.Similarity; this.stats = similarity.ComputeWeight(outerInstance.Boost, searcher.CollectionStatistics(outerInstance.term.Field), searcher.TermStatistics(outerInstance.term, termStates)); }