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 Carmit Sahar <ca...@gmail.com> on 2010/11/04 09:27:25 UTC

Weird document equals and hash through IndexReader & IndexSearcher

Hi,

I have a weird result:
If I access the same document through the IndexReader or IndexSearcher, they
are not equal and have different hash values:

                Document doc1 = indexSearcher.doc(i);
                Document doc2 = indexSearcher.getIndexReader().document(i);
                System.out.println("    Equal: " + doc1.equals(doc2) + ",
Hash: " + doc1.hashCode() + ", " + doc2.hashCode() + ", num:" + i);

I'm using Lucene 3.0.2
(No multithreads, nobody is simultaneously updating the index)
What am I missing?
Thanks
Carmit
(Could you please forward your answers to my private address as well?)

RE: Weird document equals and hash through IndexReader & IndexSearcher

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi Carmit,

equals and hashCode is not implemented for oal.document.Document, so two
instances always compare not to each other. The same happens if you retrieve
the document two times from same IndexReader.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Carmit Sahar [mailto:carmitsp@gmail.com]
> Sent: Thursday, November 04, 2010 9:27 AM
> To: java-user@lucene.apache.org
> Subject: Weird document equals and hash through IndexReader &
> IndexSearcher
> 
> Hi,
> 
> I have a weird result:
> If I access the same document through the IndexReader or IndexSearcher,
they
> are not equal and have different hash values:
> 
>                 Document doc1 = indexSearcher.doc(i);
>                 Document doc2 =
indexSearcher.getIndexReader().document(i);
>                 System.out.println("    Equal: " + doc1.equals(doc2) + ",
> Hash: " + doc1.hashCode() + ", " + doc2.hashCode() + ", num:" + i);
> 
> I'm using Lucene 3.0.2
> (No multithreads, nobody is simultaneously updating the index) What am I
> missing?
> Thanks
> Carmit
> (Could you please forward your answers to my private address as well?)


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