public virtual void TestBasics()
        {
            Directory         indexStore = NewDirectory();
            RandomIndexWriter writer     = new RandomIndexWriter(
#if FEATURE_INSTANCE_TESTDATA_INITIALIZATION
                this,
#endif
                Random, indexStore);

            for (int i = 0; i < 5; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("string", "a" + i, Field.Store.NO));
                doc.Add(new StringField("string", "b" + i, Field.Store.NO));
                writer.AddDocument(doc);
            }
            IndexReader reader = writer.GetReader();

            writer.Dispose();

            IndexSearcher          searcher = NewSearcher(reader);
            TotalHitCountCollector c        = new TotalHitCountCollector();

            searcher.Search(new MatchAllDocsQuery(), null, c);
            Assert.AreEqual(5, c.TotalHits);
            reader.Dispose();
            indexStore.Dispose();
        }
Exemple #2
0
 public ThreadAnonymousInnerClassHelper(TestSearchWithThreads outerInstance, IndexSearcher s, AtomicBoolean failed, AtomicLong netSearch)
 {
     this.OuterInstance = outerInstance;
     this.s             = s;
     this.Failed        = failed;
     this.NetSearch     = netSearch;
     col = new TotalHitCountCollector();
 }
 public ThreadAnonymousClass(TestSearchWithThreads outerInstance, IndexSearcher s, AtomicBoolean failed, AtomicInt64 netSearch)
 {
     this.outerInstance = outerInstance;
     this.s             = s;
     this.failed        = failed;
     this.netSearch     = netSearch;
     col = new TotalHitCountCollector();
 }
 private void CountHits(Analyzer analyzer, string[] docs, Query q, int expected)
 {
     Directory d = GetDirectory(analyzer, docs);
     IndexReader r = DirectoryReader.Open(d);
     IndexSearcher s = new IndexSearcher(r);
     TotalHitCountCollector c = new TotalHitCountCollector();
     s.Search(q, c);
     Assert.AreEqual(expected, c.TotalHits, q.ToString());
     r.Dispose();
     d.Dispose();
 }
Exemple #5
0
        private void CountHits(Analyzer analyzer, string[] docs, Query q, int expected)
        {
            Directory              d = GetDirectory(analyzer, docs);
            IndexReader            r = DirectoryReader.Open(d);
            IndexSearcher          s = new IndexSearcher(r);
            TotalHitCountCollector c = new TotalHitCountCollector();

            s.Search(q, c);
            Assert.AreEqual(expected, c.TotalHits, q.ToString());
            r.Dispose();
            d.Dispose();
        }
        public virtual void TestBasics()
        {
            Directory indexStore = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), indexStore, Similarity, TimeZone);
            for (int i = 0; i < 5; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("string", "a" + i, Field.Store.NO));
                doc.Add(new StringField("string", "b" + i, Field.Store.NO));
                writer.AddDocument(doc);
            }
            IndexReader reader = writer.Reader;
            writer.Dispose();

            IndexSearcher searcher = NewSearcher(reader);
            TotalHitCountCollector c = new TotalHitCountCollector();
            searcher.Search(new MatchAllDocsQuery(), null, c);
            Assert.AreEqual(5, c.TotalHits);
            reader.Dispose();
            indexStore.Dispose();
        }
        public virtual void TestBasics()
        {
            Directory         indexStore = NewDirectory();
            RandomIndexWriter writer     = new RandomIndexWriter(Random(), indexStore, Similarity, TimeZone);

            for (int i = 0; i < 5; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("string", "a" + i, Field.Store.NO));
                doc.Add(new StringField("string", "b" + i, Field.Store.NO));
                writer.AddDocument(doc);
            }
            IndexReader reader = writer.Reader;

            writer.Dispose();

            IndexSearcher          searcher = NewSearcher(reader);
            TotalHitCountCollector c        = new TotalHitCountCollector();

            searcher.Search(new MatchAllDocsQuery(), null, c);
            Assert.AreEqual(5, c.TotalHits);
            reader.Dispose();
            indexStore.Dispose();
        }
 public ThreadAnonymousInnerClassHelper(TestSearchWithThreads outerInstance, IndexSearcher s, AtomicBoolean failed, AtomicLong netSearch)
 {
     this.OuterInstance = outerInstance;
     this.s = s;
     this.Failed = failed;
     this.NetSearch = netSearch;
     col = new TotalHitCountCollector();
 }