Inheritance: Lucene.Net.Search.Spans.SpanQuery
コード例 #1
0
        public virtual void TestNoop0()
        {
            SpanQuery q1 = new SpanTermQuery(new Term("last", "sally"));
            SpanQuery q  = new FieldMaskingSpanQuery(q1, "first");

            Check(q, new int[] { }); // :EMPTY:
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        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()));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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");
        }
コード例 #13
0
        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");
        }
コード例 #14
0
        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;
            }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
		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);
		}
コード例 #19
0
		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);
		}
コード例 #20
0
        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");
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
 public virtual void TestNoop0()
 {
     SpanQuery q1 = new SpanTermQuery(new Term("last", "sally"));
     SpanQuery q = new FieldMaskingSpanQuery(q1, "first");
     Check(q, new int[] { }); // :EMPTY:
 }
コード例 #25
0
 private static void VisitQuery(FieldMaskingSpanQuery query, AzureQueryLogger.IndentedTextWriter writer)
 {
     writer.WriteLine("MaskedQuery:");
     ++writer.Indent;
     AzureQueryLogger.VisitQuery(query.MaskedQuery, writer);
     --writer.Indent;
 }
コード例 #26
0
		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");
		}