lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl Koch" <TheRan...@gmx.net>
Subject Re-Opening IndexSearcher
Date Sun, 20 Nov 2005 23:33:30 GMT
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

-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message