本文整理汇总了C#中Lucene.Net.QueryParsers.QueryParser.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# QueryParser.ToString方法的具体用法?C# QueryParser.ToString怎么用?C# QueryParser.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.QueryParsers.QueryParser
的用法示例。
在下文中一共展示了QueryParser.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBasicQueryParser
public void TestBasicQueryParser()
{
var query = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "description", new SimpleAnalyzer())
.Parse("partnum:Q36 AND SPACE");
Assert.AreEqual("+partnum:q +description:space", query.ToString(), "note Q36 -> q");
Assert.AreEqual(0, searcher.Search(query, 10).ScoreDocs.Length, "doc not found :(");
}
示例2: TestPerFieldAnalyzer
public void TestPerFieldAnalyzer()
{
var analyzer = new PerFieldAnalyzerWrapper(new SimpleAnalyzer());
analyzer.AddAnalyzer("partnum", new KeywordAnalyzer());
var query =
new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "description", analyzer)
.Parse("partnum:Q36 AND SPACE");
Assert.AreEqual("+partnum:Q36 +space", query.ToString("description"), "Q36 kept as-is");
Assert.AreEqual(1, searcher.Search(query, searcher.MaxDoc()).ScoreDocs.Length, "docs found!!!");
}
示例3: TestWithQueryParser
public void TestWithQueryParser()
{
var query =
new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "contents", synonymAnalyzer).Parse("\"fox jumps\"");
Assert.AreEqual(1, indexSearcher.Search(query, 10).TotalHits);
Console.WriteLine("With SynonymAnalyzer, \"fox jumps\" parses to {0}", query.ToString("content"));
query =
new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "contents",
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)).Parse("\"fox jumps\"");
Assert.AreEqual(1, indexSearcher.Search(query, 10).TotalHits);
Console.WriteLine("With StandardAnalyzer, \"fox jumps\" parses to {0}", query.ToString("content"));
}