public virtual void TestCJKSynonym() { BooleanQuery expected = new BooleanQuery(true); expected.Add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD); expected.Add(new TermQuery(new Term("field", "國")), BooleanClause.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", "国", BooleanClause.Occur.MUST)); }
public virtual void TestSynonyms() { BooleanQuery expected = new BooleanQuery(true); expected.Add(new TermQuery(new Term("field", "dogs")), Occur.SHOULD); expected.Add(new TermQuery(new Term("field", "dog")), 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", Occur.MUST)); Assert.AreEqual(expected, builder.CreatePhraseQuery("field", "dogs")); }
public virtual void TestTerm() { TermQuery expected = new TermQuery(new Term("field", "test")); QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random)); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "test")); }
public virtual void TestBooleanMust() { BooleanQuery expected = new BooleanQuery(); expected.Add(new TermQuery(new Term("field", "foo")), BooleanClause.Occur.MUST); expected.Add(new TermQuery(new Term("field", "bar")), BooleanClause.Occur.MUST); QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random())); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "foo bar", BooleanClause.Occur.MUST)); }
public virtual void TestBoolean() { BooleanQuery expected = new BooleanQuery(); expected.Add(new TermQuery(new Term("field", "foo")), Occur.SHOULD); expected.Add(new TermQuery(new Term("field", "bar")), Occur.SHOULD); QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random)); Assert.IsTrue(expected.Equals(builder.CreateBooleanQuery("field", "foo bar"))); //Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "foo bar")); }
public virtual void TestCJKTerm() { // individual CJK chars as terms SimpleCJKAnalyzer analyzer = new SimpleCJKAnalyzer(this); BooleanQuery expected = new BooleanQuery(); expected.Add(new TermQuery(new Term("field", "中")), BooleanClause.Occur.SHOULD); expected.Add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD); QueryBuilder builder = new QueryBuilder(analyzer); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "中国")); }
public virtual void TestCJKSynonymsAND() { BooleanQuery expected = new BooleanQuery(); expected.Add(new TermQuery(new Term("field", "中")), Occur.MUST); BooleanQuery inner = new BooleanQuery(true); inner.Add(new TermQuery(new Term("field", "国")), Occur.SHOULD); inner.Add(new TermQuery(new Term("field", "國")), Occur.SHOULD); expected.Add(inner, Occur.MUST); QueryBuilder builder = new QueryBuilder(new MockCJKSynonymAnalyzer()); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "中国", Occur.MUST)); }
public virtual void TestEmpty() { QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random)); Assert.IsNull(builder.CreateBooleanQuery("field", "")); }
public virtual void TestTerm() { TermQuery expected = new TermQuery(new Term("field", "test")); QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random())); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "test")); }
public virtual void TestMinShouldMatchNone() { QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random())); Assert.AreEqual(builder.CreateBooleanQuery("field", "one two three four"), builder.CreateMinShouldMatchQuery("field", "one two three four", 0f)); }
public virtual void TestMinShouldMatchAll() { QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random())); Assert.AreEqual(builder.CreateBooleanQuery("field", "one two three four", BooleanClause.Occur.MUST), builder.CreateMinShouldMatchQuery("field", "one two three four", 1f)); }
public virtual void TestEmpty() { QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random())); Assert.IsNull(builder.CreateBooleanQuery("field", "")); }
public virtual void TestCJKSynonymsOR2() { BooleanQuery expected = new BooleanQuery(); expected.Add(new TermQuery(new Term("field", "中")), BooleanClause.Occur.SHOULD); BooleanQuery inner = new BooleanQuery(true); inner.Add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD); inner.Add(new TermQuery(new Term("field", "國")), BooleanClause.Occur.SHOULD); expected.Add(inner, BooleanClause.Occur.SHOULD); BooleanQuery inner2 = new BooleanQuery(true); inner2.Add(new TermQuery(new Term("field", "国")), BooleanClause.Occur.SHOULD); inner2.Add(new TermQuery(new Term("field", "國")), BooleanClause.Occur.SHOULD); expected.Add(inner2, BooleanClause.Occur.SHOULD); QueryBuilder builder = new QueryBuilder(new MockCJKSynonymAnalyzer()); Assert.AreEqual(expected, builder.CreateBooleanQuery("field", "中国国")); }
public virtual void TestMinShouldMatchAll() { QueryBuilder builder = new QueryBuilder(new MockAnalyzer(Random)); Assert.AreEqual(builder.CreateBooleanQuery("field", "one two three four", Occur.MUST), builder.CreateMinShouldMatchQuery("field", "one two three four", 1f)); }
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")); }