public virtual void TestSpanNearScorerSkipTo1() { SpanNearQuery q = MakeQuery(); Weight w = Searcher.CreateNormalizedWeight(q); IndexReaderContext topReaderContext = Searcher.TopReaderContext; AtomicReaderContext leave = topReaderContext.Leaves[0]; Scorer s = w.GetScorer(leave, ((AtomicReader)leave.Reader).LiveDocs); Assert.AreEqual(1, s.Advance(1)); }
public virtual void TestSpanScorerZeroSloppyFreq() { bool ordered = true; int slop = 1; IndexReaderContext topReaderContext = searcher.TopReaderContext; IList <AtomicReaderContext> leaves = topReaderContext.Leaves; int subIndex = ReaderUtil.SubIndex(11, leaves); for (int i = 0, c = leaves.Count; i < c; i++) { AtomicReaderContext ctx = leaves[i]; Similarity sim = new DefaultSimilarityAnonymousInnerClassHelper(this); Similarity oldSim = searcher.Similarity; Scorer spanScorer; try { searcher.Similarity = sim; SpanNearQuery snq = new SpanNearQuery(new SpanQuery[] { MakeSpanTermQuery("t1"), MakeSpanTermQuery("t2") }, slop, ordered); spanScorer = searcher.CreateNormalizedWeight(snq).GetScorer(ctx, ((AtomicReader)ctx.Reader).LiveDocs); } finally { searcher.Similarity = oldSim; } if (i == subIndex) { Assert.IsTrue(spanScorer.NextDoc() != DocIdSetIterator.NO_MORE_DOCS, "first doc"); Assert.AreEqual(spanScorer.DocID + ctx.DocBase, 11, "first doc number"); float score = spanScorer.GetScore(); Assert.IsTrue(score == 0.0f, "first doc score should be zero, " + score); } else { Assert.IsTrue(spanScorer.NextDoc() == DocIdSetIterator.NO_MORE_DOCS, "no second doc"); } } }
public override void CreateWeight(IDictionary context, IndexSearcher searcher) { Weight w = searcher.CreateNormalizedWeight(q); context[this] = w; }
public SectionSearchWeight(SectionSearchQuery parent, IndexSearcher searcher, Query query) { m_parent = parent; m_weight = searcher.CreateNormalizedWeight(query); }