lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawn Zoƫ Raison <d...@digitorial.co.uk>
Subject Re: Remove Document in Lucene is not working. Code Snippet added to help.
Date Tue, 13 Dec 2011 15:52:39 GMT
Does your analyser lower case things by any chance?
If so that delete will never find anything to delete...

Dawn

On 13/12/2011 15:44, gubs wrote:
> 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
>
>

-- 

Rgds.
*Dawn Raison*


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