Thanks for your reply. But even this isn't working.
My document is not getting deleted.
Can you please suggest me something else?
On Fri, Jun 10, 2011 at 3:21 PM, Ian Lea wrote:
Try Term term = new Term("DocId", contract.getDocId());. See the
javadocs for the difference between that and what you have.
You don't need to call optimize() all the time, it at all.
--
Ian.
On Fri, Jun 10, 2011 at 9:24 AM, Pranav goyal
wrote:
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Try Term term = new Term("DocId", contract.getDocId());. See the
javadocs for the difference between that and what you have.
You don't need to call optimize() all the time, it at all.
--
Ian.
On Fri, Jun 10, 2011 at 9:24 AM, Pranav goyal
wrote:
Hi,
I tried 3-4 ways to delete a document but still no results. I am using
Lucene 3.1
I used writer.UpdateDocuments(Term term, Document d)
as well as write.addDocument(d); and after that
writer.deleteDocuments(d);
Using both I am not able to delete the previous document.
Is there any problem in my code?
String q1 = contract.getDocId();
Term term = new Term(contract.getDocId()); // where DocId is my field
try {
writer.deleteDocuments(term);
System.out.println("Deleting Document with the term "+term);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
}
d.add(new Field("DocId",q1,Field.Store.YES,Field.Index.NOT_ANALYZED));
writer.addDocument(d);
writer.optimize() ;
writer.close();
Same is the result when I use writer.updateDocument(term,d)
---------------------------------------------------------------------I tried 3-4 ways to delete a document but still no results. I am using
Lucene 3.1
I used writer.UpdateDocuments(Term term, Document d)
as well as write.addDocument(d); and after that
writer.deleteDocuments(d);
Using both I am not able to delete the previous document.
Is there any problem in my code?
String q1 = contract.getDocId();
Term term = new Term(contract.getDocId()); // where DocId is my field
try {
writer.deleteDocuments(term);
System.out.println("Deleting Document with the term "+term);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
}
d.add(new Field("DocId",q1,Field.Store.YES,Field.Index.NOT_ANALYZED));
writer.addDocument(d);
writer.optimize() ;
writer.close();
Same is the result when I use writer.updateDocument(term,d)
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
--
I'm very responsible, when ever something goes wrong they always say I'm
responsible --