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
<pranavgoyal40...@gmail.com> 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)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to