You need to do is to explicitly call commit before opening your IndexSearcher.
directory = new RAMDirectory(); iwriter = new IndexWriter(directory, config); iwriter.commit();
Now Open Searcher
ireader = DirectoryReader.open(directory); isearcher = new IndexSearcher(ireader);
Also remember you need to call commit after adding documents otherwise search may not find it. Searcher needs to reopened after commit (of course close old searcher).
iwriter.commit();
Read full article from java - org.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.RAMDirectory - Stack Overflow
No comments:
Post a Comment