lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: best way to compare Documents
Date Mon, 01 Feb 2010 09:19:53 GMT
> ...
> Is there some convenient way to compare Lucene Documents?

Not that I know of.

> I want to check if I should update a document based on whether field values have changed
and whether fields have been added or removed.
> Is it as simple as:
> newDoc.equals(oldDoc)


> I don't need to create the newDoc first, so I could compare by field. I am creating Fields
like so:
> new Field("modified", modified, Field.Store.YES, Field.Index.NOT_ANALYZED)
> So, would it be better to:
> * check oldDoc's fields count against the to be created documents desired fields count,
> * loop through the fields and compare values

Yes.  Of course you won't be able to compare unstored fields.

> Is there a better way to create Fields and/or Documents for this type of thing?

Hash or CRC as Shashi suggested, but you'll still need compare old and
new hash values.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message