From java-user-return-47096-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Sun Aug 22 19:25:06 2010 Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 59966 invoked from network); 22 Aug 2010 19:25:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Aug 2010 19:25:06 -0000 Received: (qmail 52365 invoked by uid 500); 22 Aug 2010 19:25:04 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 52314 invoked by uid 500); 22 Aug 2010 19:25:03 -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 52306 invoked by uid 99); 22 Aug 2010 19:25:03 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Aug 2010 19:25:03 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul@pauljlucas.org designates 209.85.210.48 as permitted sender) Received: from [209.85.210.48] (HELO mail-pz0-f48.google.com) (209.85.210.48) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Aug 2010 19:24:39 +0000 Received: by pzk4 with SMTP id 4so2891430pzk.35 for ; Sun, 22 Aug 2010 12:24:17 -0700 (PDT) Received: by 10.142.44.16 with SMTP id r16mr3435400wfr.319.1282505057171; Sun, 22 Aug 2010 12:24:17 -0700 (PDT) Received: from [10.0.1.4] (adsl-76-199-65-208.dsl.pltn13.sbcglobal.net [76.199.65.208]) by mx.google.com with ESMTPS id 23sm7322080wfa.22.2010.08.22.12.24.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 22 Aug 2010 12:24:16 -0700 (PDT) Sender: "Paul J. Lucas" From: "Paul J. Lucas" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: IndexWriter.deleteDocuments(Query[]) not deleting Date: Sun, 22 Aug 2010 12:24:12 -0700 Message-Id: <4370895A-AA21-439F-9601-5B3E1DCB7845@lucasmail.org> To: java-user@lucene.apache.org Mime-Version: 1.0 (Apple Message framework v1081) X-Mailer: Apple Mail (2.1081) X-Virus-Checked: Checked by ClamAV on apache.org Hi - Using Lucene 2.9.3, I'm indexing the metadata in image files. For each = image ("document" in Lucene), I have 2 additional special fields: = "FILE-PATH" (containing the full path of the file) and "DIR-PATH" = (containing the full path of the directory the file is in). The FILE-PATH Field is created only once like: private final Field m_fieldFilePath =3D new Field( "FILE-PATH", "INIT", Field.Store.YES, Field.Index.NOT_ANALYZED ); and reused; the DIR-PATH Field is created once per document like: new Field( "DIR-PATH", file.getParentFile().getAbsolutePath(), Field.Store.NO, Field.Index.NOT_ANALYZED ) (The reason the DIR-PATH Field is created once per document is because = it's part of indexing the rest of the image metadata and isn't a = special-case like FILE-PATH. I don't believe this is relevant to the = problem at hand, however.) If an image file (or an entire directory of image files) gets deleted, I = need to delete it (them) from the index. When deleting a single image, = I could do: Term fileTerm =3D new Term( "FILE-PATH", file.getAbsolutePath() = ); writer.deleteDocuments( new TermQuery( fileTerm ) ); When deleting an entire directory of images, I could do: Term dirTerm =3D new Term( "DIR-PATH", file.getAbsolutePath() ); writer.deleteDocuments( new TermQuery( dirTerm ) ); However, at the time of deletion, I don't know whether "file" refers to = a single image file or to a directory of images files. I can't do = file.isFile() or file.isDirectory() because "file" no longer exists (it = was deleted). So to cover both cases, I do: Query[] queries =3D new Query[]{ new TermQuery( fileTerm ), new TermQuery( dirTerm ) }; writer.deleteDocuments( queries ); I have non-Lucene code that monitors the filesystem for changes. For = Mac OS X, I can only get directory-level change notifications. So if a = file is deleted from a directory, I get a notification that the = directory has changed. So I delete all the documents in that directory = then re-add them. However (and here's the problem), the deletes never happen. If I delete = a file from a directory, the directory (looks like) its unindexed and = reindexed, but a query for that image file still returns a result. So = it's like the delete never happened. Why not? Additional information: I create/close a new IndexWriter for the delete. = Even if I quit the application, relaunch, and run the query, the result = still shows up (hence it's not that the current reader isn't seeing the = deletion change). - Paul --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org