コード例 #1
0
            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());
            }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: TermQuery.cs プロジェクト: sigeshitou/YAFNET
 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));
 }
コード例 #4
0
            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);
            }
コード例 #5
0
ファイル: SorterTestBase.cs プロジェクト: zhuthree/lucenenet
 public override SimWeight ComputeWeight(float queryBoost, CollectionStatistics collectionStats, params TermStatistics[] termStats)
 {
     return(@in.ComputeWeight(queryBoost, collectionStats, termStats));
 }