Hossman, thank you for clearing that up. The reason I create a new searcher for every search is that the index is frequently updated, and as far as I could read the documentation, a searcher will not detect changes in the index that occured after it was opened. I tried using just one searcher, but that did not work. As for the rest of the code, SolrJ is not available until Solr 1.3, and I actually never found the example provided at http://wiki.apache.org/solr/EmbeddedSolr (I can't see that it's linked to from the main wiki), I only found this http://wiki.apache.org/solr/SolJava.
Anyway, I'll see if I can convert my code to the logic of the example at EmbeddedSolr. hossman wrote: > > > : I haven't been able to get a profiler at the server yet, but I thought I > : might show how my code works, because it's quite different from the > example > : in the link you provided... > > i'm not even sure i really understand the orrigins of this thread, but > regardless of what the "main" topic is, regarding the specific topic of > hte code you posted: this is all a very bad idea. > > Creating a new searcher for every query is a bad idea. Using the Hits > class for any reason is a bad idea. I say all of this without > having any idea what "ResultItem" looks like, or what the code in the > "parse" method does ... they may also be bad ideas. > > If you must do "Embedded Solr" then please follow the examples from the > wiki (as i recall there is even some solrj.embedded code to make it even > easier then that), and bear in mind that this is seriously "expert" level > stuff using very low level APIs that were really never ment for most > people to see ... it is very easy to simulteneously shot yourself in the > foot while tripping over all the rope Embedded Solr gives you to hang > yourself with. > > : public synchronized ResultItem[] search(String query) throws > : CorruptIndexException, IOException{ > : SolrIndexSearcher searcher = new > SolrIndexSearcher(solrCore.getSchema(), > : "MySearcher", solrCore.getIndexDir(), true); > : Hits hits = search(searcher, query); > : for(int i =0; i < hits.length(); i++){ > : parse(hits.doc(i)); > : //add to result-array > : } > : searcher.close(); > : //return result-array > : } > : > : private Hits search(SolrIndexSearcher searcher, String pQuery){ > : try { > : SolrQueryParser parser = new SolrQueryParser(solrCore.getSchema(), > "text"); > : //default search field is called "text" > : Query query = parser.parse(pQuery); > : return searcher.search(query); > : } > : //catch exceptions > : } > > -Hoss > > -- View this message in context: http://www.nabble.com/SolrIndexWriter-holding-reference-to-deleted-file--tp14436326p14660123.html Sent from the Solr - User mailing list archive at Nabble.com.