public virtual void TestNoop0() { SpanQuery q1 = new SpanTermQuery(new Term("last", "sally")); SpanQuery q = new FieldMaskingSpanQuery(q1, "first"); Check(q, new int[] { }); // :EMPTY: }
public override bool Equals(System.Object o) { if (!(o is FieldMaskingSpanQuery)) return false; FieldMaskingSpanQuery other = (FieldMaskingSpanQuery) o; return (this.Field.Equals(other.Field) && (this.Boost == other.Boost) && this.MaskedQuery.Equals(other.MaskedQuery)); }
public override bool Equals(System.Object o) { if (!(o is FieldMaskingSpanQuery)) { return(false); } FieldMaskingSpanQuery other = (FieldMaskingSpanQuery)o; return(this.GetField().Equals(other.GetField()) && (this.GetBoost() == other.GetBoost()) && this.GetMaskedQuery().Equals(other.GetMaskedQuery())); }
public override bool Equals(object o) { if (!(o is FieldMaskingSpanQuery)) { return(false); } FieldMaskingSpanQuery other = (FieldMaskingSpanQuery)o; return(this.Field.Equals(other.Field, StringComparison.Ordinal) && (this.Boost == other.Boost) && this.MaskedQuery.Equals(other.MaskedQuery)); }
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); Assert.AreEqual(2, qr.GetTerms().Count); }
public virtual void TestRewrite0() { SpanQuery q = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); q.SetBoost(8.7654321f); SpanQuery qr = (SpanQuery)searcher.Rewrite(q); QueryUtils.CheckEqual(q, qr); Assert.AreEqual(1, qr.GetTerms().Count); }
public override bool Equals(object o) { if (!(o is FieldMaskingSpanQuery)) { return(false); } FieldMaskingSpanQuery other = (FieldMaskingSpanQuery)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.Field.Equals(other.Field, StringComparison.Ordinal) && (NumericUtils.SingleToSortableInt32(this.Boost) == NumericUtils.SingleToSortableInt32(other.Boost)) && this.MaskedQuery.Equals(other.MaskedQuery)); }
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); HashSet <Term> terms = new HashSet <Term>(); qr.ExtractTerms(terms); Assert.AreEqual(1, terms.Count); }
public virtual void TestRewrite1() { // mask an anon SpanQuery class that rewrites to something else. SpanQuery q = new FieldMaskingSpanQuery(new SpanTermQueryAnonymousInnerClassHelper(this, new Term("last", "sally")), "first"); SpanQuery qr = (SpanQuery)Searcher.Rewrite(q); QueryUtils.CheckUnequal(q, qr); HashSet <Term> terms = new HashSet <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); }
public virtual void TestSpans1() { SpanQuery q1 = new SpanTermQuery(new Term("first", "sally")); SpanQuery q2 = new SpanTermQuery(new Term("first", "james")); SpanQuery qA = new SpanOrQuery(new SpanQuery[] { q1, q2 }); SpanQuery qB = new FieldMaskingSpanQuery(qA, "id"); Check(qA, new int[] { 0, 1, 2, 4 }); Check(qB, new int[] { 0, 1, 2, 4 }); Spans spanA = qA.GetSpans(searcher.GetIndexReader()); Spans spanB = qB.GetSpans(searcher.GetIndexReader()); while (spanA.Next()) { Assert.IsTrue(spanB.Next(), "spanB not still going"); Assert.AreEqual(S(spanA), S(spanB), "spanA not equal spanB"); } Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done"); }
public virtual void TestSpans1() { SpanQuery q1 = new SpanTermQuery(new Term("first", "sally")); SpanQuery q2 = new SpanTermQuery(new Term("first", "james")); SpanQuery qA = new SpanOrQuery(q1, q2); SpanQuery qB = new FieldMaskingSpanQuery(qA, "id"); Check(qA, new int[] { 0, 1, 2, 4 }); Check(qB, new int[] { 0, 1, 2, 4 }); Spans spanA = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, qA); Spans spanB = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, qB); while (spanA.Next()) { Assert.IsTrue(spanB.Next(), "spanB not still going"); Assert.AreEqual(s(spanA), s(spanB), "spanA not equal spanB"); } Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done"); }
public override Query Rewrite(IndexReader reader) { FieldMaskingSpanQuery clone = null; SpanQuery rewritten = (SpanQuery) maskedQuery.Rewrite(reader); if (rewritten != maskedQuery) { clone = (FieldMaskingSpanQuery) this.Clone(); clone.maskedQuery = rewritten; } if (clone != null) { return clone; } else { return this; } }
public virtual void TestEquality1() { SpanQuery q1 = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); SpanQuery q2 = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); SpanQuery q3 = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "XXXXX"); SpanQuery q4 = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "XXXXX")), "first"); SpanQuery q5 = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("xXXX", "sally")), "first"); QueryUtils.CheckEqual(q1, q2); QueryUtils.CheckUnequal(q1, q3); QueryUtils.CheckUnequal(q1, q4); QueryUtils.CheckUnequal(q1, q5); SpanQuery qA = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); qA.Boost = 9f; SpanQuery qB = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); QueryUtils.CheckUnequal(qA, qB); qB.Boost = 9f; QueryUtils.CheckEqual(qA, qB); }
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); }
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 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); Assert.AreEqual(2, qr.GetTerms().Count); }
public virtual void TestRewrite0() { SpanQuery q = new FieldMaskingSpanQuery(new SpanTermQuery(new Term("last", "sally")), "first"); q.SetBoost(8.7654321f); SpanQuery qr = (SpanQuery) searcher.Rewrite(q); QueryUtils.CheckEqual(q, qr); Assert.AreEqual(1, qr.GetTerms().Count); }
public virtual void TestRewrite1() { // mask an anon SpanQuery class that rewrites to something else. SpanQuery q = new FieldMaskingSpanQuery(new SpanTermQueryAnonymousInnerClassHelper(this, new Term("last", "sally")), "first"); SpanQuery qr = (SpanQuery)Searcher.Rewrite(q); QueryUtils.CheckUnequal(q, qr); HashSet<Term> terms = new HashSet<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); HashSet<Term> terms = new HashSet<Term>(); qr.ExtractTerms(terms); Assert.AreEqual(1, terms.Count); }
private static void VisitQuery(FieldMaskingSpanQuery query, AzureQueryLogger.IndentedTextWriter writer) { writer.WriteLine("MaskedQuery:"); ++writer.Indent; AzureQueryLogger.VisitQuery(query.MaskedQuery, writer); --writer.Indent; }
public virtual void TestSpans1() { SpanQuery q1 = new SpanTermQuery(new Term("first", "sally")); SpanQuery q2 = new SpanTermQuery(new Term("first", "james")); SpanQuery qA = new SpanOrQuery(new SpanQuery[]{q1, q2}); SpanQuery qB = new FieldMaskingSpanQuery(qA, "id"); Check(qA, new int[]{0, 1, 2, 4}); Check(qB, new int[]{0, 1, 2, 4}); Spans spanA = qA.GetSpans(searcher.GetIndexReader()); Spans spanB = qB.GetSpans(searcher.GetIndexReader()); while (spanA.Next()) { Assert.IsTrue(spanB.Next(), "spanB not still going"); Assert.AreEqual(S(spanA), S(spanB), "spanA not equal spanB"); } Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done"); }