Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 84F379473 for ; Fri, 16 Dec 2011 16:54:40 +0000 (UTC) Received: (qmail 41788 invoked by uid 500); 16 Dec 2011 16:54:38 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 41743 invoked by uid 500); 16 Dec 2011 16:54:38 -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 41735 invoked by uid 99); 16 Dec 2011 16:54:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 16:54:38 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_REPLYTO,FREEMAIL_REPLYTO_END_DIGIT,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul_t100@fastmail.fm designates 66.111.4.27 as permitted sender) Received: from [66.111.4.27] (HELO out3.smtp.messagingengine.com) (66.111.4.27) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 16:54:29 +0000 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 784E721A58 for ; Fri, 16 Dec 2011 11:54:08 -0500 (EST) Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute4.internal (MEProxy); Fri, 16 Dec 2011 11:54:08 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= message-id:date:from:reply-to:mime-version:to:subject :content-type:content-transfer-encoding; s=mesmtp; bh=GzoyWSewHp kyZf0Wz2/sIaoN5uo=; b=qcHpbQBHhHg68Cs87OaX/WpdukOc5CJAki/UOxnEG+ IhpQ3Hw/5Q8n59bxO0VKNL+DsMZ6w/D+Psfk7T8Qf4CjWaYw1PJa1K3FkncOGUOP t8kAYts8+7W88bUsB9vvP4RQLru8K904srJopagox0o0CrCZfU1glvAzhkRSmsf1 E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:reply-to :mime-version:to:subject:content-type:content-transfer-encoding; s=smtpout; bh=GzoyWSewHpkyZf0Wz2/sIaoN5uo=; b=D88q8vp0J+YZdFjb1 vw+CV3bv4RgbJSCKROh5fwUK32Ufjn+IbnVsVYfXsxHxMNnVB91VndElPNm5tmQe MD8lt0FXfLLk38HnrhM0ThZliBlxJutwH2hGkfxLb+GbSDTOXLrvZ9ZRNcH2VvUG d89GV+tIIC/nDu4PCBE6ZNuSaY= X-Sasl-enc: c6I4Lcuf12odJcqMjKZk/0xRUJtcL3423ZzC2kK1FcWJ 1324054448 Received: from macbook.lan (unknown [217.155.98.246]) by mail.messagingengine.com (Postfix) with ESMTPSA id EE8138E0209 for ; Fri, 16 Dec 2011 11:54:07 -0500 (EST) Message-ID: <4EEB77AD.1070102@fastmail.fm> Date: Fri, 16 Dec 2011 16:54:05 +0000 From: Paul Taylor Reply-To: paul_t100@fastmail.fm User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Why is the old value still in the index Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I'm adding documents to an index, at a later date I modify a document and update the index, close the writer and open a new IndexReader. My indexreader iterates over terms for that field and docFreq() returns one as I would expect, however the iterator returns both the old value of the document and the new value, I don't expect (or want) the old value to still be in the index, so why is this. This full test program generates: TermDocsFreq1 test TermDocsFreq1 test test2 Dont expect to see 'test' listed the second time package com.jthink.jaikoz; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.*; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.Version; public class LuceneTest { public static void main(String []args) { try { String FIELD1="field1"; RAMDirectory dir = new RAMDirectory(); IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUCENE_35)); IndexWriter iw = new IndexWriter(dir, iwc); Document document = new Document(); document.add(new Field(FIELD1,"test", Field.Store.YES, Field.Index.ANALYZED)); iw.addDocument(document); iw.close(); IndexReader ir = IndexReader.open(dir,true); TermEnum terms = ir.terms(new Term(FIELD1)); System.out.println("TermDocsFreq"+terms.docFreq()); do { if (terms.term() != null) { System.out.println(terms.term().text()); } } while (terms.next() && terms.term().field().equals(FIELD1)); IndexWriterConfig iwc2 = new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUCENE_35)); iw = new IndexWriter(dir, iwc2); document = new Document(); document.add(new Field(FIELD1,"test2", Field.Store.YES, Field.Index.ANALYZED)); iw.updateDocument(new Term(FIELD1,"term1"),document); iw.close(); ir = IndexReader.open(dir,true); terms = ir.terms(new Term(FIELD1)); System.out.println("TermDocsFreq"+terms.docFreq()); do { if (terms.term() != null) { System.out.println(terms.term().text()); } } while (terms.next() && terms.term().field().equals(FIELD1)); } catch(Exception ex) { ex.printStackTrace(); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org