You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ismail Siddiqui <is...@gmail.com> on 2006/10/15 07:59:09 UTC
problem deleting documents
hi guys
i am having problem deleting documents .. apparently its not doin it.. here
is the code snippet
public void delete(final BoardMessage message)
{
try{
IndexReader fsReader;
if (index.exists()) {
fsReader =IndexReader.open(index);
fsReader.deleteDocuments(new Term("pk",message.getId()+""));
fsReader.close();
}
}
catch(IOException e){
e.printStackTrace();
}
now pk is primary key which i am storing but not indexing it..
doc.add(new Field("pk", message.getId().toString(),Field.Store.YES,
Field.Index.NO));
when i am making a search i can get pk and show it in result...but above
code is not deleting the document
Re: problem deleting documents
Posted by Ismail Siddiqui <is...@gmail.com>.
thanks, it worked
On 10/15/06, Doron Cohen <DO...@il.ibm.com> wrote:
>
> > now pk is primary key which i am storing but not indexing it..
> > doc.add(new Field("pk", message.getId().toString(),Field.Store.YES,
> > Field.Index.NO));
>
> You would need to index it for this to work.
> From javadocs for IndexReader.deleteDocuments(Term):
> Deletes all documents _containing_ term
> Containment relates to indexed terms.
>
> >
> > when i am making a search i can get pk and show it in result...but above
> > code is not deleting the document
>
> - Doron
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
Re: problem deleting documents
Posted by Doron Cohen <DO...@il.ibm.com>.
> now pk is primary key which i am storing but not indexing it..
> doc.add(new Field("pk", message.getId().toString(),Field.Store.YES,
> Field.Index.NO));
You would need to index it for this to work.
>From javadocs for IndexReader.deleteDocuments(Term):
Deletes all documents _containing_ term
Containment relates to indexed terms.
>
> when i am making a search i can get pk and show it in result...but above
> code is not deleting the document
- Doron
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: problem deleting documents
Posted by cf...@jwpepper.com.
Ismail,
I was having the same type of problem (using v2) until I changed
my index to change the ID field from Field.Index.TOKENIZED to
Field.Index.UN_TOKENIZED. Can you try that, or create a secondary field
that is set up that way with your pk id in it?
Chris
"Ismail Siddiqui" <is...@gmail.com>
10/15/2006 01:58 AM
Please respond to
java-user@lucene.apache.org
To
java-user@lucene.apache.org
cc
Subject
problem deleting documents
hi guys
i am having problem deleting documents .. apparently its not doin it..
here
is the code snippet
public void delete(final BoardMessage message)
{
try{
IndexReader fsReader;
if (index.exists()) {
fsReader =IndexReader.open(index);
fsReader.deleteDocuments(new Term("pk",message.getId()+""));
fsReader.close();
}
}
catch(IOException e){
e.printStackTrace();
}
now pk is primary key which i am storing but not indexing it..
doc.add(new Field("pk", message.getId().toString(),Field.Store.YES,
Field.Index.NO));
when i am making a search i can get pk and show it in result...but above
code is not deleting the document