0

I've just installed Solr/Lucene on a Windows machine simply to test its capability. I've indexed a couple hundred files and I'm able to successfully query the indexed content through the web interface. Given that the web interface isn't too user friendly I thought I'd try to create a simple application to do a full text search over the indexed content. So far I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Lucene.Net;

namespace solrTest
{
    class Program
    {
        static void Main(string[] args)
        {

            string indexFileLocation = @"C:\solr-5.3.1\server\solr\test\data\index";
            Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.Open(indexFileLocation);

            Lucene.Net.Search.IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir);

            Lucene.Net.Index.Term searchTerm = new Lucene.Net.Index.Term("ID", "1");
            Lucene.Net.Search.Query query = new Lucene.Net.Search.TermQuery(searchTerm);

            Lucene.Net.Search.TopDocs results = searcher.Search(query, null, 10);

            foreach(Lucene.Net.Search.ScoreDoc test in results.ScoreDocs)
            {
                Console.WriteLine(test.ToString());
                Console.ReadLine();
            }

        }
    }
}

When running the code I receive an error stating:

An unhandled exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
Additional information: read past EOF

I know I'm missing something obvious. Your help would be greatly appreciated.

Edit: I downloaded Luke.Net and received the same error.

  • Since Lucene.NET is open source, why don't you include it as a project in your solution, then step through the Lucene code to find out what exactly is causing the exception? – user8128167 Oct 07 '15 at 21:23
  • Thank you user89861 - The error is caused by "Lucene.Net.Search.IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir);" – user3582260 Oct 08 '15 at 00:09
  • so, the problem is solved now or what? – Mysterion Oct 08 '15 at 09:48

0 Answers0