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 Ricardo Coutinho <rc...@odyssey-group.com> on 2003/11/04 11:16:43 UTC

Removing indexed document

Hi all,

I am trying to delete an indexed document. I followed an example but I am
not getting the results I expect...

This is my test case.
I have index 2 documents with unique keywords so that I can recognise them
i.e.

...
...
doc.add(Field.Keyword("uri",
"jdbc://theHost/thePath#uuid=8dc8946e0a28645e01a428240000000e");
writer.addDocument(doc);
writer.close();
...

and

...
...
doc.add(Field.Keyword("uri",
"jdbc://theHost/thePath#uuid=8c5419bc0a28645e0089db9a0000016b");
writer.addDocument(doc);
writer.close();

...


My problem is that when I pass in the id for document
'8c5419bc0a28645e0089db9a0000016b', Lucene is removing document
'8dc8946e0a28645e01a428240000000e'

This is my code for the delete

TermEnum uidIter = reader.terms(new Term("uri",
"jdbc://theHost/thePath#uuid=8c5419bc0a28645e0089db9a0000016b");
while(uidIter.next())
{
	Term t = uidIter.term();
	getLogger().debug("unindexing text() " + t.text());

	reader.delete(t);
}

My debug statement shows me that it deletes the wrong document...
10:59:30,577 DEBUG [DocumentIndexerService] unindexing text()
jdbc://theHost/thePath#uuid=8dc8946e0a28645e01a428240000000e

I am quite new to Lucene so all healp is gratly appreciated

Thanks


Ricardo
__________________________________________________________________________
* This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
* Any unauthorized copying, disclosure, or distribution of the material
within
this email is strictly forbidden.
* Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Asset Management
Systems SA unless otherwise specifically stated.
* An electronic message is not binding on its sender.  Any message referring
to
a binding engagement must be confirmed in writing and duly signed.
* If you have received this email in error, please notify the sender
immediately
and delete the original.

Re: Removing indexed document

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Tuesday, November 4, 2003, at 05:16  AM, Ricardo Coutinho wrote:
> This is my code for the delete
>
> TermEnum uidIter = reader.terms(new Term("uri",
> "jdbc://theHost/thePath#uuid=8c5419bc0a28645e0089db9a0000016b");
> while(uidIter.next())
> {
> 	Term t = uidIter.term();
> 	getLogger().debug("unindexing text() " + t.text());
>
> 	reader.delete(t);
> }
>
> My debug statement shows me that it deletes the wrong document...
> 10:59:30,577 DEBUG [DocumentIndexerService] unindexing text()
> jdbc://theHost/thePath#uuid=8dc8946e0a28645e01a428240000000e

If you only want to delete a single document, why are you iterating?   
What you are doing is starting the enumeration at the term from  
reader.terms() and then deleting all documents from there forward,  
except you are doing a .next() first and skipping the one you really  
wanted to delete.  To delete just the one you want, do this:

  	reader.delete(new  
Term("uri","jdbc://theHost/ 
thePath#uuid=8c5419bc0a28645e0089db9a0000016b"))

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org