Karl, You are opening IndexSearchers in this code but not closing them. If GC & finalizers don't happen to run before you run out of file handles, you will get exceptions.
You could close the IndexSearcher after every request, but it would lead to very poor performance. Better to keep a single searcher open to service all requests. -Yonik Now hiring -- http://forms.cnet.com/slink?231706 On 11/20/05, Karl Koch <[EMAIL PROTECTED]> wrote: > Hello, > > how do I close and open an IndexSearcher object in order to free resources > that cause my system to throw an IOException saing "Too many open files" as > well as trouble with an index lock file ? > > I have the following code: > > synchronized public static Hits search(String queryString, String[] > searchFields, > String indexDirectory) { > // create access to index > SnowballAnalyzer analyser = new SnowballAnalyzer("English", > MyAnalyser.STOP_WORDS); > Hits hits = null; > ContentSelection result = null; > > if (indexDirectory != null && indexDirectory != ""){ > SnowballSearcher.indexDirectory = indexDirectory; > } > if (queryString == "" || queryString == null){ > return null; // no query => no results > } > try { > IndexSearcher searcher = new > IndexSearcher(SnowballSearcher.indexDirectory); > if (searchFields.length > 1){ > // search over multiple index fields > Query query = > MultiFieldQueryParser.parse(queryString, searchFields, > analyser); > hits = searcher.search(query); > } > // wrap the Hits object in a result object > } catch (Exception exception) { > exception.printStackTrace(); > } > return hits; > } > > Do you see any other problem in this code that could cause those problems? > > Karl --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]