public virtual void TestComplexSpanChecks() { SpanTermQuery one = new SpanTermQuery(new Term("field", "one")); SpanTermQuery thous = new SpanTermQuery(new Term("field", "thousand")); //should be one position in between SpanTermQuery hundred = new SpanTermQuery(new Term("field", "hundred")); SpanTermQuery three = new SpanTermQuery(new Term("field", "three")); SpanNearQuery oneThous = new SpanNearQuery(new SpanQuery[] { one, thous }, 0, true); SpanNearQuery hundredThree = new SpanNearQuery(new SpanQuery[] { hundred, three }, 0, true); SpanNearQuery oneThousHunThree = new SpanNearQuery(new SpanQuery[] { oneThous, hundredThree }, 1, true); SpanQuery query; //this one's too small query = new SpanPositionRangeQuery(oneThousHunThree, 1, 2); CheckHits(query, new int[] { }); //this one's just right query = new SpanPositionRangeQuery(oneThousHunThree, 0, 6); CheckHits(query, new int[] { 1103, 1203, 1303, 1403, 1503, 1603, 1703, 1803, 1903 }); var payloads = new List <byte[]>(); BytesRef pay = new BytesRef(("pos: " + 0).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay2 = new BytesRef(("pos: " + 1).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay3 = new BytesRef(("pos: " + 3).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay4 = new BytesRef(("pos: " + 4).GetBytes(IOUtils.CHARSET_UTF_8)); payloads.Add(pay.Bytes); payloads.Add(pay2.Bytes); payloads.Add(pay3.Bytes); payloads.Add(pay4.Bytes); query = new SpanNearPayloadCheckQuery(oneThousHunThree, payloads); CheckHits(query, new int[] { 1103, 1203, 1303, 1403, 1503, 1603, 1703, 1803, 1903 }); }
public override object Clone() { SpanPositionRangeQuery result = new SpanPositionRangeQuery((SpanQuery)m_match.Clone(), m_start, m_end); result.Boost = Boost; return(result); }
public virtual void TestFuzzy() { FuzzyQuery fq = new FuzzyQuery(new Term("field", "broan")); SpanQuery sfq = new SpanMultiTermQueryWrapper<MultiTermQuery>(fq); // will not match quick brown fox SpanPositionRangeQuery sprq = new SpanPositionRangeQuery(sfq, 3, 6); Assert.AreEqual(2, searcher.Search(sprq, 10).TotalHits); }
public virtual void TestFuzzy2() { // maximum of 1 term expansion FuzzyQuery fq = new FuzzyQuery(new Term("field", "broan"), 1, 0, 1, false); SpanQuery sfq = new SpanMultiTermQueryWrapper<MultiTermQuery>(fq); // will only match jumps over lazy broun dog SpanPositionRangeQuery sprq = new SpanPositionRangeQuery(sfq, 0, 100); Assert.AreEqual(1, searcher.Search(sprq, 10).TotalHits); }
public override bool Equals(object o) { if (this == o) { return(true); } if (!(o is SpanPositionRangeQuery)) { return(false); } SpanPositionRangeQuery other = (SpanPositionRangeQuery)o; return(this.m_end == other.m_end && this.m_start == other.m_start && this.m_match.Equals(other.m_match) && this.Boost == other.Boost); }
public virtual void TestSpanPositionRange() { SpanPositionRangeQuery query; SpanTermQuery term1 = new SpanTermQuery(new Term("field", "five")); query = new SpanPositionRangeQuery(term1, 1, 2); CheckHits(query, new int[] { 25, 35, 45, 55, 65, 75, 85, 95 }); Assert.IsTrue(Searcher.Explain(query, 25).Value > 0.0f); Assert.IsTrue(Searcher.Explain(query, 95).Value > 0.0f); query = new SpanPositionRangeQuery(term1, 0, 1); CheckHits(query, new int[] { 5, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599 }); query = new SpanPositionRangeQuery(term1, 6, 7); CheckHits(query, new int[] { }); }
public override bool Equals(object o) { if (this == o) { return(true); } if (!(o is SpanPositionRangeQuery)) { return(false); } SpanPositionRangeQuery other = (SpanPositionRangeQuery)o; // LUCENENET specific - compare bits rather than using equality operators to prevent these comparisons from failing in x86 in .NET Framework with optimizations enabled return(this.m_end == other.m_end && this.m_start == other.m_start && this.m_match.Equals(other.m_match) && NumericUtils.SingleToSortableInt32(this.Boost) == NumericUtils.SingleToSortableInt32(other.Boost)); }
public virtual void TestComplexSpanChecks() { SpanTermQuery one = new SpanTermQuery(new Term("field", "one")); SpanTermQuery thous = new SpanTermQuery(new Term("field", "thousand")); //should be one position in between SpanTermQuery hundred = new SpanTermQuery(new Term("field", "hundred")); SpanTermQuery three = new SpanTermQuery(new Term("field", "three")); SpanNearQuery oneThous = new SpanNearQuery(new SpanQuery[] { one, thous }, 0, true); SpanNearQuery hundredThree = new SpanNearQuery(new SpanQuery[] { hundred, three }, 0, true); SpanNearQuery oneThousHunThree = new SpanNearQuery(new SpanQuery[] { oneThous, hundredThree }, 1, true); SpanQuery query; //this one's too small query = new SpanPositionRangeQuery(oneThousHunThree, 1, 2); CheckHits(query, new int[] { }); //this one's just right query = new SpanPositionRangeQuery(oneThousHunThree, 0, 6); CheckHits(query, new int[] { 1103, 1203, 1303, 1403, 1503, 1603, 1703, 1803, 1903 }); var payloads = new List<byte[]>(); BytesRef pay = new BytesRef(("pos: " + 0).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay2 = new BytesRef(("pos: " + 1).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay3 = new BytesRef(("pos: " + 3).GetBytes(IOUtils.CHARSET_UTF_8)); BytesRef pay4 = new BytesRef(("pos: " + 4).GetBytes(IOUtils.CHARSET_UTF_8)); payloads.Add(pay.Bytes); payloads.Add(pay2.Bytes); payloads.Add(pay3.Bytes); payloads.Add(pay4.Bytes); query = new SpanNearPayloadCheckQuery(oneThousHunThree, payloads); CheckHits(query, new int[] { 1103, 1203, 1303, 1403, 1503, 1603, 1703, 1803, 1903 }); }
public virtual void TestFuzzy() { FuzzyQuery fq = new FuzzyQuery(new Term("field", "broan")); SpanQuery sfq = new SpanMultiTermQueryWrapper<MultiTermQuery>(fq); // will not match quick brown fox SpanPositionRangeQuery sprq = new SpanPositionRangeQuery(sfq, 3, 6); Assert.AreEqual(2, Searcher.Search(sprq, 10).TotalHits); }
public virtual void TestFuzzy2() { // maximum of 1 term expansion FuzzyQuery fq = new FuzzyQuery(new Term("field", "broan"), 1, 0, 1, false); SpanQuery sfq = new SpanMultiTermQueryWrapper<MultiTermQuery>(fq); // will only match jumps over lazy broun dog SpanPositionRangeQuery sprq = new SpanPositionRangeQuery(sfq, 0, 100); Assert.AreEqual(1, Searcher.Search(sprq, 10).TotalHits); }
public override object Clone() { SpanPositionRangeQuery result = new SpanPositionRangeQuery((SpanQuery)match.Clone(), start, end); result.Boost = Boost; return result; }