A filter that includes documents that match with a specific term.
Inheritance: Lucene.Net.Search.Filter
Beispiel #1
0
        public void TestHashCodeAndEquals()
        {
            int num = AtLeast(100);
            for (int i = 0; i < num; i++)
            {
                string field1 = @"field" + i;
                string field2 = @"field" + i + num;
                string value1 = TestUtil.RandomRealisticUnicodeString(Random());
                string value2 = value1 + @"x";
                TermFilter filter1 = TermFilter(field1, value1);
                TermFilter filter2 = TermFilter(field1, value2);
                TermFilter filter3 = TermFilter(field2, value1);
                TermFilter filter4 = TermFilter(field2, value2);
                var filters = new TermFilter[]
                {
                    filter1, filter2, filter3, filter4
                };

                for (int j = 0; j < filters.Length; j++)
                {
                    TermFilter termFilter = filters[j];
                    for (int k = 0; k < filters.Length; k++)
                    {
                        TermFilter otherTermFilter = filters[k];
                        if (j == k)
                        {
                            assertEquals(termFilter, otherTermFilter);
                            assertEquals(termFilter.GetHashCode(), otherTermFilter.GetHashCode());
                            assertTrue(termFilter.Equals(otherTermFilter));
                        }
                        else
                        {
                            assertFalse(termFilter.Equals(otherTermFilter));
                        }
                    }
                }

                TermFilter filter5 = TermFilter(field2, value2);
                assertEquals(filter5, filter4);
                assertEquals(filter5.GetHashCode(), filter4.GetHashCode());
                assertTrue(filter5.Equals(filter4));
                assertEquals(filter5, filter4);
                assertTrue(filter5.Equals(filter4));
            }
        }
Beispiel #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }

            TermFilter that = (TermFilter)o;

            if (term != null ? !term.Equals(that.term) : that.term != null)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
 public DocIdSetAnonymousInnerClassHelper(TermFilter outerInstance, Bits acceptDocs, TermsEnum termsEnum)
 {
     this.outerInstance = outerInstance;
     this.acceptDocs = acceptDocs;
     this.termsEnum = termsEnum;
 }
Beispiel #4
0
 public void TestToString()
 {
     var termsFilter = new TermFilter(new Term("field1", "a"));
     assertEquals(@"field1:a", termsFilter.ToString());
 }
Beispiel #5
0
 public DocIdSetAnonymousInnerClassHelper(TermFilter outerInstance, Bits acceptDocs, TermsEnum termsEnum)
 {
     this.outerInstance = outerInstance;
     this.acceptDocs    = acceptDocs;
     this.termsEnum     = termsEnum;
 }