You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by it99 <de...@syrres.com> on 2010/04/07 15:19:23 UTC

Errors deleting index

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