lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From it99 <deswiatlow...@syrres.com>
Subject Errors deleting index
Date Wed, 07 Apr 2010 13:19:23 GMT

I create an IndexWriter, index and then close the IndexWriter.

Then if I delte the index files it does this great.

        try
        {
            FSDirectory dir = FSDirectory.getDirectory(directory);
            for(String fileName : dir.list())
            {
                dir.deleteFile(fileName);
            }
        }
        catch(IOException ioe)
        {
            ioe.printStackTrace();
        }


But if in between creating index and deleting, I create a multi-searcher,
and close, I get IOExceptions when trying to delete the index.

    private MultiSearcher initSearcher(Collection<Directory> indexes)
        throws CorruptIndexException, IOException
    {
        IndexSearcher[] searchers = new IndexSearcher[indexes.size()];
        Iterator<Directory> it = indexes.iterator();
        int i = 0;
        while (it.hasNext())
        {
            searchers[i] = new IndexSearcher(it.next());
            i++;
        }

        return new MultiSearcher(searchers);
    }



    private void close()
    {
    	try 
    	{

			searcher.close();

			
			if(searcher instanceof MultiSearcher)
			{
				MultiSearcher ms  = (MultiSearcher)searcher;
				ms.close();
				for(Searchable s :Arrays.asList(ms.getSearchables()))
				{

					s.close();
				}
			}
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}
    }
-- 
View this message in context: http://n3.nabble.com/Errors-deleting-index-tp702962p702962.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

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


Mime
View raw message