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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to