lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MMach...@LEVI.com
Subject Delete files
Date Mon, 14 Jul 2003 09:11:00 GMT
Hi, I am new in Lucene. I have a problem with my code. Somebody can help me
why I can't delete some files.Maybe I missing something. Thanks in advance.

Regards,

Michel

 

Here the two code that I use for indexing files and for delete files: the
error message is the following:  java.io.IOException: Index locked for
write: Lock@C:\yo\write.lock

      at org.apache.lucene.index.IndexReader.delete(Unknown Source)

      at indice.deletefile.main(deletefile.java:15)

Exception in thread "main"

 

 

package indice;

 

import org.apache.lucene.index.IndexWriter;

import org.apache.lucene.analysis.SimpleAnalyzer;

import org.apache.lucene.document.Document;

import org.apache.lucene.document.Field;

import java.io.*;

 

 

public class IndexarFile {

      public static void main(String[] args) throws Exception{

            String indexPath = "c:\\yo";

            IndexWriter writer;

            String f = "c:\\PROCEDURES\\BCNDMPRD.xls";

            writer = new IndexWriter(indexPath, new SimpleAnalyzer(),
false);

            

            //for (int i=0; i<args.length; i++) {

                  //System.out.println("Indexando file " + args[i]);

                  

                  //InputStream file = new FileInputStream(args[i]);

                  InputStream file = new FileInputStream(f);

                  Document doc = new Document();

                  doc.add(Field.UnIndexed("path", f));

                  doc.add(Field.Text("body", (Reader)new
InputStreamReader(file)));

                  

                  writer.addDocument(doc);

                  file.close();

            //}

            writer.close();

      }

}

 

 

 

package indice;

 

import org.apache.lucene.index.IndexReader;

import org.apache.lucene.index.IndexWriter;

import org.apache.lucene.analysis.SimpleAnalyzer;

//import org.apache.lucene.document.Document;

/**import org.apache.lucene.document.Field;

import java.io.*;*/

 

public class deletefile {

      public static void main(String[] args) throws Exception{

            String path = "c:\\yo";

            IndexWriter iw = new IndexWriter(path, new SimpleAnalyzer(),
false);

            IndexReader reader = IndexReader.open(path);

            reader.delete(1);

            reader.close();

            iw.optimize();

            iw.close();

            System.out.println("reader.numDocs() : " + reader.numDocs());

            System.out.println("reader.indexExists() : " +
reader.indexExists(path));

            

      }

}     


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message