"it is very easy to simultaneously shoot yourself in the foot while tripping over all the rope <insert package here> gives you to hang yourself with"
I'm writing that one down and posting it on my wall <G>. Erick On Jan 6, 2008 3:25 AM, Chris Hostetter <[EMAIL PROTECTED]> 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 >