示例#1
0
        public virtual void TestInOrderWithMinShouldMatch()
        {
            Directory         dir = NewDirectory();
            RandomIndexWriter w   = new RandomIndexWriter(
#if FEATURE_INSTANCE_TESTDATA_INITIALIZATION
                this,
#endif
                Random, dir);
            Document doc = new Document();

            doc.Add(NewTextField("field", "some text here", Field.Store.NO));
            w.AddDocument(doc);
            IndexReader r = w.GetReader();

            w.Dispose();
            IndexSearcher s  = new IndexSearcherAnonymousInnerClassHelper(this, r);
            BooleanQuery  bq = new BooleanQuery();

            bq.Add(new TermQuery(new Term("field", "some")), Occur.SHOULD);
            bq.Add(new TermQuery(new Term("field", "text")), Occur.SHOULD);
            bq.Add(new TermQuery(new Term("field", "here")), Occur.SHOULD);
            bq.MinimumNumberShouldMatch = 2;
            s.Search(bq, 10);
            r.Dispose();
            dir.Dispose();
        }
示例#2
0
        public virtual void TestInOrderWithMinShouldMatch()
        {
            Directory         dir = NewDirectory();
            RandomIndexWriter w   = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
            Document          doc = new Document();

            doc.Add(NewTextField("field", "some text here", Field.Store.NO));
            w.AddDocument(doc);
            IndexReader r = w.Reader;

            w.Dispose();
            IndexSearcher s  = new IndexSearcherAnonymousInnerClassHelper(this, r);
            BooleanQuery  bq = new BooleanQuery();

            bq.Add(new TermQuery(new Term("field", "some")), BooleanClause.Occur.SHOULD);
            bq.Add(new TermQuery(new Term("field", "text")), BooleanClause.Occur.SHOULD);
            bq.Add(new TermQuery(new Term("field", "here")), BooleanClause.Occur.SHOULD);
            bq.MinimumNumberShouldMatch = 2;
            s.Search(bq, 10);
            r.Dispose();
            dir.Dispose();
        }
 public virtual void TestInOrderWithMinShouldMatch()
 {
     Directory dir = NewDirectory();
     RandomIndexWriter w = new RandomIndexWriter(Random(), dir);
     Document doc = new Document();
     doc.Add(NewTextField("field", "some text here", Field.Store.NO));
     w.AddDocument(doc);
     IndexReader r = w.Reader;
     w.Dispose();
     IndexSearcher s = new IndexSearcherAnonymousInnerClassHelper(this, r);
     BooleanQuery bq = new BooleanQuery();
     bq.Add(new TermQuery(new Term("field", "some")), BooleanClause.Occur.SHOULD);
     bq.Add(new TermQuery(new Term("field", "text")), BooleanClause.Occur.SHOULD);
     bq.Add(new TermQuery(new Term("field", "here")), BooleanClause.Occur.SHOULD);
     bq.MinimumNumberShouldMatch = 2;
     s.Search(bq, 10);
     r.Dispose();
     dir.Dispose();
 }