Example #1
0
		public SpanWeight(SpanQuery query, Searcher searcher)
		{
			this.similarity = query.GetSimilarity(searcher);
			this.query = query;
            terms = new Support.Set<Lucene.Net.Index.Term>();
			query.ExtractTerms(terms);
			idfExp = similarity.idfExplain(terms.ToArray(), searcher);
			idf = idfExp.GetIdf();
		}
Example #2
0
		public SpanWeight(SpanQuery query, Searcher searcher)
		{
			this.similarity = query.GetSimilarity(searcher);
			this.query = query;
			terms = new System.Collections.Hashtable();
			query.ExtractTerms(terms);
			idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
			idf = idfExp.GetIdf();
		}
        public SpanWeight(SpanQuery query, Searcher searcher)
        {
            this.similarity = query.GetSimilarity(searcher);
            this.query = query;
            terms = new System.Collections.Hashtable();
            query.ExtractTerms(terms);

            System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);

            idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
        }
Example #4
0
        public SpanWeight(SpanQuery query, Searcher searcher)
        {
            this.similarity = query.GetSimilarity(searcher);
            this.internalQuery = query;

            terms = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet<Term>();
            query.ExtractTerms(terms);

            idfExp = similarity.IdfExplain(terms, searcher);
            idf = idfExp.Idf;
        }
Example #5
0
        public SpanWeight(SpanQuery query, Searcher searcher)
        {
            this.similarity = query.GetSimilarity(searcher);
            this.query      = query;
            terms           = new System.Collections.Hashtable();
            query.ExtractTerms(terms);

            System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);

            idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
        }
        public virtual void  TestRewrite1()
        {
            // mask an anon SpanQuery class that rewrites to something else.
            SpanQuery q = new FieldMaskingSpanQuery(new AnonymousClassSpanTermQuery(this, new Term("last", "sally")), "first");

            SpanQuery qr = (SpanQuery)searcher.Rewrite(q);

            QueryUtils.CheckUnequal(q, qr);

            var terms = Support.Compatibility.SetFactory.CreateHashSet <Term>();

            qr.ExtractTerms(terms);
            Assert.AreEqual(2, terms.Count);
        }
        public virtual void  TestRewrite0()
        {
            SpanQuery q = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first");

            q.Boost = 8.7654321f;
            SpanQuery qr = (SpanQuery)searcher.Rewrite(q);

            QueryUtils.CheckEqual(q, qr);

            var terms = Support.Compatibility.SetFactory.CreateHashSet <Term>();

            qr.ExtractTerms(terms);
            Assert.AreEqual(1, terms.Count);
        }
Example #8
0
 public static Spans Wrap(IndexReaderContext topLevelReaderContext, SpanQuery query)
 {
     IDictionary<Term, TermContext> termContexts = new Dictionary<Term, TermContext>();
     SortedSet<Term> terms = new SortedSet<Term>();
     query.ExtractTerms(terms);
     foreach (Term term in terms)
     {
         termContexts[term] = TermContext.Build(topLevelReaderContext, term);
     }
     IList<AtomicReaderContext> leaves = topLevelReaderContext.Leaves();
     if (leaves.Count == 1)
     {
         AtomicReaderContext ctx = leaves[0];
         return query.GetSpans(ctx, ((AtomicReader)ctx.Reader()).LiveDocs, termContexts);
     }
     return new MultiSpansWrapper(leaves, query, termContexts);
 }
Example #9
0
        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);
            }
        }
Example #10
0
 public override void ExtractTerms(ICollection <Lucene.Net.Index.Term> terms)
 {
     maskedQuery.ExtractTerms(terms);
 }