本文整理汇总了C#中Lucene.Net.QueryParsers.QueryParser.GetDefaultOperator方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParser.GetDefaultOperator方法的具体用法?C# QueryParser.GetDefaultOperator怎么用?C# QueryParser.GetDefaultOperator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.QueryParsers.QueryParser
的用法示例。
在下文中一共展示了QueryParser.GetDefaultOperator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSimple
public virtual void TestSimple()
{
AssertQueryEquals("term term term", null, "term term term");
AssertQueryEquals("türm term term", new WhitespaceAnalyzer(), "türm term term");
AssertQueryEquals("ümlaut", new WhitespaceAnalyzer(), "ümlaut");
AssertQueryEquals("\"\"", new KeywordAnalyzer(), "");
AssertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");
AssertQueryEquals("a AND b", null, "+a +b");
AssertQueryEquals("(a AND b)", null, "+a +b");
AssertQueryEquals("c OR (a AND b)", null, "c (+a +b)");
AssertQueryEquals("a AND NOT b", null, "+a -b");
AssertQueryEquals("a AND -b", null, "+a -b");
AssertQueryEquals("a AND !b", null, "+a -b");
AssertQueryEquals("a && b", null, "+a +b");
AssertQueryEquals("a && ! b", null, "+a -b");
AssertQueryEquals("a OR b", null, "a b");
AssertQueryEquals("a || b", null, "a b");
AssertQueryEquals("a OR !b", null, "a -b");
AssertQueryEquals("a OR ! b", null, "a -b");
AssertQueryEquals("a OR -b", null, "a -b");
AssertQueryEquals("+term -term term", null, "+term -term term");
AssertQueryEquals("foo:term AND field:anotherTerm", null, "+foo:term +anotherterm");
AssertQueryEquals("term AND \"phrase phrase\"", null, "+term +\"phrase phrase\"");
AssertQueryEquals("\"hello there\"", null, "\"hello there\"");
Assert.IsTrue(GetQuery("a AND b", null) is BooleanQuery);
Assert.IsTrue(GetQuery("hello", null) is TermQuery);
Assert.IsTrue(GetQuery("\"hello there\"", null) is PhraseQuery);
AssertQueryEquals("germ term^2.0", null, "germ term^2.0");
AssertQueryEquals("(term)^2.0", null, "term^2.0");
AssertQueryEquals("(germ term)^2.0", null, "(germ term)^2.0");
AssertQueryEquals("term^2.0", null, "term^2.0");
AssertQueryEquals("term^2", null, "term^2.0");
AssertQueryEquals("\"germ term\"^2.0", null, "\"germ term\"^2.0");
AssertQueryEquals("\"term germ\"^2", null, "\"term germ\"^2.0");
AssertQueryEquals("(foo OR bar) AND (baz OR boo)", null, "+(foo bar) +(baz boo)");
AssertQueryEquals("((a OR b) AND NOT c) OR d", null, "(+(a b) -c) d");
AssertQueryEquals("+(apple \"steve jobs\") -(foo bar baz)", null, "+(apple \"steve jobs\") -(foo bar baz)");
AssertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null, "+(title:dog title:cat) -author:\"bob dole\"");
QueryParser qp = new QueryParser("field", new StandardAnalyzer());
// make sure OR is the default:
Assert.AreEqual(QueryParser.OR_OPERATOR, qp.GetDefaultOperator());
qp.SetDefaultOperator(QueryParser.AND_OPERATOR);
Assert.AreEqual(QueryParser.AND_OPERATOR, qp.GetDefaultOperator());
qp.SetDefaultOperator(QueryParser.OR_OPERATOR);
Assert.AreEqual(QueryParser.OR_OPERATOR, qp.GetDefaultOperator());
}