Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

problem deleting documents

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


ismail at gmail

Oct 14, 2006, 10:59 PM

Post #1 of 4 (1650 views)
Permalink
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


DORONC at il

Oct 14, 2006, 11:10 PM

Post #2 of 4 (1569 views)
Permalink
Re: problem deleting documents [In reply to]

> 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[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


ismail at gmail

Oct 15, 2006, 3:18 AM

Post #3 of 4 (1552 views)
Permalink
Re: problem deleting documents [In reply to]

thanks, it worked

On 10/15/06, Doron Cohen <DORONC[at]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[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>


cfowler at jwpepper

Oct 15, 2006, 5:47 AM

Post #4 of 4 (1561 views)
Permalink
Re: problem deleting documents [In reply to]

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" <ismail[at]gmail.com>
10/15/2006 01:58 AM
Please respond to
java-user[at]lucene.apache.org


To
java-user[at]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

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.