Пример #1
0
        public virtual void TestAllDocs()
        {
            InitializeIndex(new string[] { "A", "B", "C", "D" });
            IndexReader    reader   = DirectoryReader.Open(Dir);
            IndexSearcher  searcher = NewSearcher(reader);
            TermRangeQuery query    = new TermRangeQuery("content", null, null, true, true);
            Terms          terms    = MultiFields.GetTerms(searcher.IndexReader, "content");

            Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
            Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
            query = new TermRangeQuery("content", null, null, false, false);
            Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
            Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
            query = TermRangeQuery.NewStringRange("content", "", null, true, false);
            Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
            Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
            // and now anothe one
            query = TermRangeQuery.NewStringRange("content", "B", null, true, false);
            Assert.IsTrue(query.GetTermsEnum(terms) is TermRangeTermsEnum);
            Assert.AreEqual(3, searcher.Search(query, null, 1000).ScoreDocs.Length);
            reader.Dispose();
        }
Пример #2
0
 public virtual void TestAllDocs()
 {
     InitializeIndex(new string[] { "A", "B", "C", "D" });
     IndexReader reader = DirectoryReader.Open(Dir);
     IndexSearcher searcher = NewSearcher(reader);
     TermRangeQuery query = new TermRangeQuery("content", null, null, true, true);
     Terms terms = MultiFields.GetTerms(searcher.IndexReader, "content");
     Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
     Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
     query = new TermRangeQuery("content", null, null, false, false);
     Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
     Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
     query = TermRangeQuery.NewStringRange("content", "", null, true, false);
     Assert.IsFalse(query.GetTermsEnum(terms) is TermRangeTermsEnum);
     Assert.AreEqual(4, searcher.Search(query, null, 1000).ScoreDocs.Length);
     // and now anothe one
     query = TermRangeQuery.NewStringRange("content", "B", null, true, false);
     Assert.IsTrue(query.GetTermsEnum(terms) is TermRangeTermsEnum);
     Assert.AreEqual(3, searcher.Search(query, null, 1000).ScoreDocs.Length);
     reader.Dispose();
 }