Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 80791 invoked from network); 29 Apr 2005 02:47:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Apr 2005 02:47:12 -0000 Received: (qmail 34474 invoked by uid 500); 29 Apr 2005 02:48:17 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 34129 invoked by uid 500); 29 Apr 2005 02:48:15 -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 34116 invoked by uid 99); 29 Apr 2005 02:48:15 -0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FORGED_YAHOO_RCVD X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from web31102.mail.mud.yahoo.com (HELO web31102.mail.mud.yahoo.com) (68.142.200.35) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 28 Apr 2005 19:48:15 -0700 Received: (qmail 35289 invoked by uid 60001); 29 Apr 2005 02:47:00 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=VXkUoWaaZovasljoabHIBV0e6HFiTDOU5ZUzFVAofpnWSGy6mfnGH5JYTtbV8bBbEiIC9XdtQQVpNOlozACjMnPf7ySChR8ZxhaiHOh5ORO3/NLH3Qn3D14vEgDpvinoaYs56pvArSUVFRzQH9wfh8M+7RWTo5lZPFuHD7vTIMY= ; Message-ID: <20050429024700.35287.qmail@web31102.mail.mud.yahoo.com> Received: from [69.201.130.192] by web31102.mail.mud.yahoo.com via HTTP; Thu, 28 Apr 2005 19:47:00 PDT Date: Thu, 28 Apr 2005 19:47:00 -0700 (PDT) From: Otis Gospodnetic Subject: Re: Deletes and Hits To: java-user@lucene.apache.org In-Reply-To: 6667 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Let's see: import org.apache.lucene.search.*; import org.apache.lucene.index.*; import org.apache.lucene.analysis.SimpleAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; public class HitDocDeleteTest { static String indexDir = "/tmp/hddt"; static int numDocsAdd = 2; static int docId = 0; public static void main(String[] args) throws Exception { index(); search(); } static void index() throws Exception { IndexWriter writerMain = new IndexWriter(indexDir, new SimpleAnalyzer(), true); for (docId = 0; docId < numDocsAdd; docId++) { Document doc = new Document(); doc.add(Field.Text("Content", "This is for document number " + docId)); doc.add(Field.Keyword("DocID", Integer.toString(docId))); writerMain.addDocument(doc); } writerMain.optimize(); writerMain.close(); } static void search() throws Exception { IndexSearcher isearcher = new IndexSearcher(indexDir); Hits hits = isearcher.search(new TermQuery(new Term("Content", "document"))); System.out.println("HITS: " + hits.length()); System.out.println("DOC0: " + hits.doc(0)); System.out.println("DOC1: " + hits.doc(1)); IndexReader reader = IndexReader.open(indexDir); reader.delete(1); reader.close(); System.out.println("HITS: " + hits.length()); System.out.println("DOC0: " + hits.doc(0)); System.out.println("DOC1: " + hits.doc(1)); } } java HitDocDeleteTest HITS: 2 DOC0: Document stored/uncompressed,indexed> DOC1: Document stored/uncompressed,indexed> HITS: 2 DOC0: Document stored/uncompressed,indexed> DOC1: Document stored/uncompressed,indexed> See also: http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#isDeleted(int) Otis --- Scott Smith wrote: > Suppose I do a search and get a hit list. Before I access the hit > list, > my delete routine (running in another thread) comes along and deletes > some documents. What happens if I now try to access documents that > have > been deleted? > > > > Scott > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org