lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carmit Sahar <>
Subject Weird document equals and hash through IndexReader & IndexSearcher
Date Thu, 04 Nov 2010 09:19:49 GMT
Thanks, Uwe!
Indeed you're right! Whenever IndexReader is called, a new document instance is
created! And since the Document class does no override equals &
hashCode, I can't know if the same doc was

retrieved. And since Document is final, I can only write a wrapper for it.
Is this an oversight or intentional?
In any case, it's not too convenient...

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

-----Original Message-----
From: Carmit Sahar []
Sent: Thursday, November 04, 2010 9:27 AM
Subject: Weird document equals and hash through IndexReader &


I have a weird result:
If I access the same document through the IndexReader or IndexSearcher,


are not equal and have different hash values:

                Document doc1 = indexSearcher.doc(i);
                Document doc2 =


                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
(Could you please forward your answers to my private address as well?)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message