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 SpanWeight(SpanQuery query, IndexSearcher searcher) { this.m_similarity = searcher.Similarity; this.m_query = query; m_termContexts = new Dictionary <Term, TermContext>(); ISet <Term> terms = new JCG.SortedSet <Term>(); query.ExtractTerms(terms); IndexReaderContext context = searcher.TopReaderContext; TermStatistics[] termStats = new TermStatistics[terms.Count]; int i = 0; foreach (Term term in terms) { TermContext state = TermContext.Build(context, term); termStats[i] = searcher.TermStatistics(term, state); m_termContexts[term] = state; i++; } string field = query.Field; if (field != null) { m_stats = m_similarity.ComputeWeight(query.Boost, searcher.CollectionStatistics(query.Field), termStats); } }
public TermWeight(TermQuery outerInstance, IndexSearcher searcher, TermContext termStates) { this.outerInstance = outerInstance; Debug.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)); }
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 override SimWeight ComputeWeight(float queryBoost, CollectionStatistics collectionStats, params TermStatistics[] termStats) { return(@in.ComputeWeight(queryBoost, collectionStats, termStats)); }