Esempio n. 1
0
 public virtual void TestCJKSynonymsPhrase()
 {
     MultiPhraseQuery expected = new MultiPhraseQuery();
     expected.Add(new Term("field", "中"));
     expected.Add(new Term[] { new Term("field", "国"), new Term("field", "國") });
     QueryBuilder builder = new QueryBuilder(new MockCJKSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国"));
     expected.Slop = 3;
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国", 3));
 }
Esempio n. 2
0
 public virtual void TestSynonyms()
 {
     BooleanQuery expected = new BooleanQuery(true);
     expected.Add(new TermQuery(new Term("field", "dogs")), BooleanClause.Occur.SHOULD);
     expected.Add(new TermQuery(new Term("field", "dog")), BooleanClause.Occur.SHOULD);
     QueryBuilder builder = new QueryBuilder(new MockSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "dogs"));
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "dogs"));
     Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "dogs", BooleanClause.Occur.MUST));
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "dogs"));
 }
Esempio n. 3
0
 public virtual void TestSynonymsPhrase()
 {
     MultiPhraseQuery expected = new MultiPhraseQuery();
     expected.Add(new Term("field", "old"));
     expected.Add(new Term[] { new Term("field", "dogs"), new Term("field", "dog") });
     QueryBuilder builder = new QueryBuilder(new MockSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "old dogs"));
 }
Esempio n. 4
0
        public virtual void TestCJKSynonym()
        {
            BooleanQuery expected = new BooleanQuery(true);

            expected.Add(new TermQuery(new Term("field", "国")), Occur.SHOULD);
            expected.Add(new TermQuery(new Term("field", "國")), Occur.SHOULD);
            QueryBuilder builder = new QueryBuilder(new MockCJKSynonymAnalyzer());

            Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "国"));
            Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "国"));
            Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "国", Occur.MUST));
        }
Esempio n. 5
0
        public virtual void TestCJKPhrase()
        {
            // individual CJK chars as terms
            SimpleCJKAnalyzer analyzer = new SimpleCJKAnalyzer(this);

            PhraseQuery expected = new PhraseQuery();
            expected.Add(new Term("field", "中"));
            expected.Add(new Term("field", "国"));

            QueryBuilder builder = new QueryBuilder(analyzer);
            Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国"));
        }
Esempio n. 6
0
        public virtual void TestPhraseQueryPositionIncrements()
        {
            PhraseQuery expected = new PhraseQuery();
            expected.Add(new Term("field", "1"));
            expected.Add(new Term("field", "2"), 2);

            CharacterRunAutomaton stopList = new CharacterRunAutomaton((new RegExp("[sS][tT][oO][pP]")).ToAutomaton());

            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, false, stopList);

            QueryBuilder builder = new QueryBuilder(analyzer);
            Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "1 stop 2"));
        }
Esempio n. 7
0
        public virtual void TestCJKSloppyPhrase()
        {
            // individual CJK chars as terms
            SimpleCJKAnalyzer analyzer = new SimpleCJKAnalyzer(this);

            PhraseQuery expected = new PhraseQuery();
            expected.Slop = 3;
            expected.Add(new Term("field", "中"));
            expected.Add(new Term("field", "国"));

            QueryBuilder builder = new QueryBuilder(analyzer);
            Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国", 3));
        }
Esempio n. 8
0
 public virtual void TestSynonymsPhrase()
 {
     MultiPhraseQuery expected = new MultiPhraseQuery();
     expected.Add(new Term("field", "old"));
     expected.Add(new Term[] { new Term("field", "dogs"), new Term("field", "dog") });
     QueryBuilder builder = new QueryBuilder(new MockSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "old dogs"));
 }
Esempio n. 9
0
 public virtual void TestSynonyms()
 {
     BooleanQuery expected = new BooleanQuery(true);
     expected.Add(new TermQuery(new Term("field", "dogs")), BooleanClause.Occur.SHOULD);
     expected.Add(new TermQuery(new Term("field", "dog")), BooleanClause.Occur.SHOULD);
     QueryBuilder builder = new QueryBuilder(new MockSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "dogs"));
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "dogs"));
     Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "dogs", BooleanClause.Occur.MUST));
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "dogs"));
 }
Esempio n. 10
0
        public virtual void TestPhraseQueryPositionIncrements()
        {
            PhraseQuery expected = new PhraseQuery();
            expected.Add(new Term("field", "1"));
            expected.Add(new Term("field", "2"), 2);

            CharacterRunAutomaton stopList = new CharacterRunAutomaton((new RegExp("[sS][tT][oO][pP]")).ToAutomaton());

            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, false, stopList);

            QueryBuilder builder = new QueryBuilder(analyzer);
            Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "1 stop 2"));
        }
Esempio n. 11
0
 public virtual void TestCJKSynonymsPhrase()
 {
     MultiPhraseQuery expected = new MultiPhraseQuery();
     expected.Add(new Term("field", "中"));
     expected.Add(new Term[] { new Term("field", "国"), new Term("field", "國") });
     QueryBuilder builder = new QueryBuilder(new MockCJKSynonymAnalyzer());
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国"));
     expected.Slop = 3;
     Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "中国", 3));
 }