lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gubs <gub...@gmail.com>
Subject Remove Document in Lucene is not working. Code Snippet added to help.
Date Tue, 13 Dec 2011 15:44:12 GMT
Hi,

I created a new document with 2 fields below code. 

String[] names = {"Gubendran", "kavitha"};
		for ( String name :  names) {
			luceneIndexWriter.createDocument(iw, name);
		}


private void createDocument(IndexWriter iw, String name) throws
CorruptIndexException,
			IOException {
		// Creating document to add using indexWriter
		Document doc = new Document();

		Field nameField = new Field("name", name, Field.Store.YES,
				Field.Index.ANALYZED);

		// Add fields into document
		doc.add(nameField);
		iw.addDocument(doc);
}

Later used below code to delete document. But, when i do indexSearcher the
data in document still exist. Any help ?
// Delete the Document
		luceneIndexWriter.deleteDocument("Gubendran");

private void deleteDocument(String name) throws IOException {
		Directory dir = FSDirectory.open(new File(INDEX_DIR));
		IndexReader ir = IndexReader.open(dir, false);
		ir.deleteDocuments(new Term("name", "Gubendran"));
		ir.close();
	}

Thanks and i appreciate

Gubs


--
View this message in context: http://lucene.472066.n3.nabble.com/Remove-Document-in-Lucene-is-not-working-Code-Snippet-added-to-help-tp3582660p3582660.html
Sent from the Lucene - General mailing list archive at Nabble.com.

Mime
View raw message