// Called by one node once it has reopened, to notify all // other nodes. this is just a mock (since it goes and // directly updates all other nodes, in RAM)... in a real // env this would hit the wire, sending version & // collection stats to all other nodes: internal virtual void BroadcastNodeReopen(int nodeID, long version, IndexSearcher newSearcher) { if (Verbose) { Console.WriteLine("REOPEN: nodeID=" + nodeID + " version=" + version + " maxDoc=" + newSearcher.IndexReader.MaxDoc); } // Broadcast new collection stats for this node to all // other nodes: foreach (string field in fieldsToShare) { CollectionStatistics stats = newSearcher.CollectionStatistics(field); foreach (NodeState node in m_nodes) { // Don't put my own collection stats into the cache; // we pull locally: if (node.MyNodeID != nodeID) { node.collectionStatsCache[new FieldAndShardVersion(nodeID, version, field)] = stats; } } } foreach (NodeState node in m_nodes) { node.UpdateNodeVersion(nodeID, version); } }
internal SlowMinShouldMatchScorer(BooleanWeight weight, AtomicReader reader, IndexSearcher searcher) : base(weight) { this.Dv = reader.GetSortedSetDocValues("dv"); this.MaxDoc = reader.MaxDoc; BooleanQuery bq = (BooleanQuery)weight.Query; this.MinNrShouldMatch = bq.MinimumNumberShouldMatch; this.Sims = new SimScorer[(int)Dv.ValueCount]; foreach (BooleanClause clause in bq.Clauses) { Debug.Assert(!clause.Prohibited); Debug.Assert(!clause.Required); Term term = ((TermQuery)clause.Query).Term; long ord = Dv.LookupTerm(term.Bytes); if (ord >= 0) { bool success = Ords.Add(ord); Debug.Assert(success); // no dups TermContext context = TermContext.Build(reader.Context, term); SimWeight w = weight.Similarity.ComputeWeight(1f, searcher.CollectionStatistics("field"), searcher.TermStatistics(term, context)); var dummy = w.ValueForNormalization; // ignored w.Normalize(1F, 1F); Sims[(int)ord] = weight.Similarity.DoSimScorer(w, (AtomicReaderContext)reader.Context); } } }
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 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 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_Renamed.Field()), searcher.TermStatistics(outerInstance.Term_Renamed, 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 SpanWeight(SpanQuery query, IndexSearcher searcher) { this.Similarity = searcher.Similarity; this.query = query; TermContexts = new Dictionary<Term, TermContext>(); SortedSet<Term> terms = new 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); TermContexts[term] = state; i++; } string field = query.Field; if (field != null) { Stats = Similarity.ComputeWeight(query.Boost, searcher.CollectionStatistics(query.Field), termStats); } }
// Called by one node once it has reopened, to notify all // other nodes. this is just a mock (since it goes and // directly updates all other nodes, in RAM)... in a real // env this would hit the wire, sending version & // collection stats to all other nodes: internal virtual void BroadcastNodeReopen(int nodeID, long version, IndexSearcher newSearcher) { if (VERBOSE) { Console.WriteLine("REOPEN: nodeID=" + nodeID + " version=" + version + " maxDoc=" + newSearcher.IndexReader.MaxDoc); } // Broadcast new collection stats for this node to all // other nodes: foreach (string field in FieldsToShare) { CollectionStatistics stats = newSearcher.CollectionStatistics(field); foreach (NodeState node in Nodes) { // Don't put my own collection stats into the cache; // we pull locally: if (node.MyNodeID != nodeID) { node.CollectionStatsCache[new FieldAndShardVersion(nodeID, version, field)] = stats; } } } foreach (NodeState node in Nodes) { node.UpdateNodeVersion(nodeID, version); } }