Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 42601 invoked from network); 1 Feb 2010 09:20:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Feb 2010 09:20:44 -0000 Received: (qmail 3317 invoked by uid 500); 1 Feb 2010 09:20:41 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 3257 invoked by uid 500); 1 Feb 2010 09:20:41 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 3247 invoked by uid 99); 1 Feb 2010 09:20:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Feb 2010 09:20:41 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 209.85.218.209 as permitted sender) Received: from [209.85.218.209] (HELO mail-bw0-f209.google.com) (209.85.218.209) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Feb 2010 09:20:33 +0000 Received: by bwz1 with SMTP id 1so2162854bwz.12 for ; Mon, 01 Feb 2010 01:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=fdY7u/4jsS3w9SpC8uERJbRqsRWlpzYEdX+/qZ2LVoE=; b=rELGte9PtX9cLx+dO0z3nT+B9Egn9jumlkt8VqSlBchkOHvNMb+Q6kZ54gUQ0NX1RM RFq7wQK+HKEbl+S9CkhUQReLVJLbORyTcNiFfzrUhREOFh2Fqa/Y8N5UxvPtJTJDlW6O FoNtoSEqC4VHYZ5s6onLH0xQaHVLqeuHCxs8c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=XDe4JbrsTlReNWghdO9f03d0JnuT8trdx2VAi9fImNE6m6Rj6WPNPYSXGBb9x+nFCy 7xtEIfBDOXUWv77V6jgIp0SLLIllsxHeGS0ePl7Z5wKHrEPRHmjEFwjth0V8OxpFYjVd bZ7ijC45lqIQpQc0jt51MbhXIBL7LwUWvkrEM= MIME-Version: 1.0 Received: by 10.204.156.28 with SMTP id u28mr3000531bkw.74.1265016013264; Mon, 01 Feb 2010 01:20:13 -0800 (PST) In-Reply-To: <6CA9B075-90B5-411D-9CD8-B799F3DF77BC@koberg.com> References: <6CA9B075-90B5-411D-9CD8-B799F3DF77BC@koberg.com> From: Ian Lea Date: Mon, 1 Feb 2010 09:19:53 +0000 Message-ID: <8c4e68611002010119k34299a9dgfc2d59b6301ac0a0@mail.gmail.com> Subject: Re: best way to compare Documents To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org > ... > 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) No! > 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, and > * 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. -- Ian. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org