2

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);
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
Peter
  • 21
  • 1

3 Answers3

0

I would pull out something like ILSpy to examine what methods actually are available.

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29
0

This is just a problem with the case of the method names. It's GetIndexReader() for example not getIndexReader(). You are probably basing this on docs for the Java implementation.

Dillorscroft
  • 253
  • 1
  • 3
  • 10
0

in Lucene.net this method's name is IndexReader.