As a newbie to Lucene.Net/Lucene and to C# I was able to put some lines of code and have a search running.
Now I want to get a snippet of the found area back. I have found below code but Visual Studio keeps telling me that a) "Searcher does contain a definition of getIndexReader" and b) "ScoreDoc does not contain a definition of doc" -and I don't get the point where the problem is!
Is there anybody out there who can help.
I am using Lucene.Net 3.0.3 and Lucene Contrib 3.0.3 on Visual Studio 2010 Express.
See the code I have below.
Thanks for your help!
RC
IndexReader indexReader = IndexReader.Open(directory, true);
Searcher indexSearch = new IndexSearcher(indexReader);
var queryParser = new QueryParser(Version.LUCENE_30, "text", analyzer);
var query = queryParser.Parse("\"system AKZ\"~10");
Console.WriteLine("Searching for: " + query);
TopDocs hits = indexSearch.Search(query,500);
/// Highlighter
FastVectorHighlighter fvHighlighter = new FastVectorHighlighter(true, true);
for (int i = 0; i < hits.ScoreDocs.Length; i++)
{
string bestfragment fvHighlighter.GetBestFragment(fvHighlighter.GetFieldQuery(query),indexSearch.getIndexReader(), hits.ScoreDocs[i].doc, "text", 20);
MessageBox.Show(bestfragment);
}
Console.WriteLine("Results Found: " + hits.TotalHits);