本文整理汇总了C#中IndexSearcher.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IndexSearcher.Close方法的具体用法?C# IndexSearcher.Close怎么用?C# IndexSearcher.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexSearcher
的用法示例。
在下文中一共展示了IndexSearcher.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: search
public static void search(String indexDir, String q)
{
Directory dir = FSDriecotry.Open(new System.IO.FileInfo(indexDir));
IndexSearcher searcher = new IndexSearcher(dir, true);
QueryParser parser = new QueryParser("contents", new StandardAnalyzer(Version.LUCENE_CURRENT));
Query query = parser.Parser(q);
Lucene.Net.Saerch.TopDocs hits = searher.Search(query, 10);
System.Console.WriteLine("Found " + hits.totalHits + " document(s) that matched query '" + q + "':");
for (int i = 0; i < hits.scoreDocs.Length; i++) {
ScoreDoc scoreDoc = hits.ScoreDoc[i];
Document doc = searcher.Doc(scoreDoc.doc);
System.Console.WriteLine(doc.Get("filename"));
}
searcher.Close();
}
示例2: SearchIndex
private void SearchIndex()
{
String q = "t_text1:random";
QueryParser parser = new QueryParser(TEST_VERSION, "t_text1", a);
Query query = parser.Parse(q);
IndexSearcher searcher = new IndexSearcher(dir, true);
// This scorer can return negative idf -> null fragment
IScorer scorer = new QueryTermScorer(query, searcher.IndexReader, "t_text1");
// This scorer doesn't use idf (patch version)
//Scorer scorer = new QueryTermScorer( query, "t_text1" );
Highlighter h = new Highlighter(scorer);
TopDocs hits = searcher.Search(query, null, 10);
for (int i = 0; i < hits.TotalHits; i++)
{
Document doc = searcher.Doc(hits.ScoreDocs[i].Doc);
String result = h.GetBestFragment(a, "t_text1", doc.Get("t_text1"));
Console.WriteLine("result:" + result);
Assert.AreEqual(result, "more <B>random</B> words for second field");
}
searcher.Close();
}