本文整理汇总了C#中Lucene.Net.QueryParsers.QueryParser.SetMultiTermRewriteMethod方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParser.SetMultiTermRewriteMethod方法的具体用法?C# QueryParser.SetMultiTermRewriteMethod怎么用?C# QueryParser.SetMultiTermRewriteMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.QueryParsers.QueryParser
的用法示例。
在下文中一共展示了QueryParser.SetMultiTermRewriteMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFarsiRangeCollating
public virtual void TestFarsiRangeCollating()
{
RAMDirectory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.Add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES, Field.Index.UN_TOKENIZED));
iw.AddDocument(doc);
iw.Close();
IndexSearcher is_Renamed = new IndexSearcher(ramDir);
QueryParser qp = new QueryParser("content", new WhitespaceAnalyzer());
// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
// RuleBasedCollator. However, the Arabic Locale seems to order the Farsi
// characters properly.
System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("ar").CompareInfo;
qp.SetRangeCollator(c);
// Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
// orders the U+0698 character before the U+0633 character, so the single
// index Term below should NOT be returned by a ConstantScoreRangeQuery
// with a Farsi Collator (or an Arabic one for the case when Farsi is not
// supported).
// Test ConstantScoreRangeQuery
qp.SetMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
ScoreDoc[] result = is_Renamed.Search(qp.Parse("[ \u062F TO \u0698 ]"), null, 1000).ScoreDocs;
Assert.AreEqual(0, result.Length, "The index Term should not be included.");
result = is_Renamed.Search(qp.Parse("[ \u0633 TO \u0638 ]"), null, 1000).ScoreDocs;
Assert.AreEqual(1, result.Length, "The index Term should be included.");
// Test TermRangeQuery
qp.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
result = is_Renamed.Search(qp.Parse("[ \u062F TO \u0698 ]"), null, 1000).ScoreDocs;
Assert.AreEqual(0, result.Length, "The index Term should not be included.");
result = is_Renamed.Search(qp.Parse("[ \u0633 TO \u0638 ]"), null, 1000).ScoreDocs;
Assert.AreEqual(1, result.Length, "The index Term should be included.");
is_Renamed.Close();
}
示例2: TestRange
public virtual void TestRange()
{
AssertQueryEquals("[ a TO z]", null, "[a TO z]");
Assert.AreEqual(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((TermRangeQuery) GetQuery("[ a TO z]", null)).GetRewriteMethod());
QueryParser qp = new QueryParser("field", new SimpleAnalyzer());
qp.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
Assert.AreEqual(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE, ((TermRangeQuery) qp.Parse("[ a TO z]")).GetRewriteMethod());
AssertQueryEquals("[ a TO z ]", null, "[a TO z]");
AssertQueryEquals("{ a TO z}", null, "{a TO z}");
AssertQueryEquals("{ a TO z }", null, "{a TO z}");
AssertQueryEquals("{ a TO z }^2.0", null, "{a TO z}^2.0");
AssertQueryEquals("[ a TO z] OR bar", null, "[a TO z] bar");
AssertQueryEquals("[ a TO z] AND bar", null, "+[a TO z] +bar");
AssertQueryEquals("( bar blar { a TO z}) ", null, "bar blar {a TO z}");
AssertQueryEquals("gack ( bar blar { a TO z}) ", null, "gack (bar blar {a TO z})");
}