Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 30452 invoked from network); 8 Oct 2004 17:36:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Oct 2004 17:36:35 -0000 Received: (qmail 34222 invoked by uid 500); 8 Oct 2004 17:36:13 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 34165 invoked by uid 500); 8 Oct 2004 17:36:13 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 34141 invoked by uid 99); 8 Oct 2004 17:36:13 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [209.10.110.95] (HELO londo.swishmail.com) (209.10.110.95) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 08 Oct 2004 10:36:11 -0700 Received: (qmail 5747 invoked by uid 89); 8 Oct 2004 17:36:05 -0000 Received: from unknown (HELO ?192.168.168.81?) (postmaster@cottrell-cutting.net@24.5.163.156) by londo.swishmail.com with AES256-SHA encrypted SMTP; 8 Oct 2004 17:36:05 -0000 Message-ID: <4166CF5F.7090206@apache.org> Date: Fri, 08 Oct 2004 10:33:19 -0700 From: Doug Cutting User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040806 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Lucene Users List Subject: Re: locking problems References: <000001c4ad48$948bb190$0a00a8c0@aadlaptop> In-Reply-To: <000001c4ad48$948bb190$0a00a8c0@aadlaptop> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Aad Nales wrote: > 1. can I have one or multiple searchers open when I open a writer? > 2. can I have one or multiple readers open when I open a writer? Yes, with one caveat: if you've called the IndexReader methods delete(), undelete() or setNorm() then you may not open an IndexWriter until you've closed that IndexReader instance. In general, only a single object may modify an index at once, but many may access it simultaneously in a read-only manner, including while it is modified. Indexes are modified by either an IndexWriter or by the IndexReader methods delete(), undelete() and setNorm(). Typically an application which modifies and searches simultaneously should keep the following open: 1. A single IndexReader instance used for all searches, perhaps opened via an IndexSearcher. Periodically, as the index changes, this is discarded, and replaced with a new instance. 2. Either: a. An IndexReader to delete documents. b. An IndexWriter to add documents; or So an updating thread might open (2a), delete old documents, close it, then open (2b) add new documents, perhaps optimize, then close. At this point, when the index has been updated (1) can be discarded and replaced with a new instance. Typically the old instance of (1) is not explicitly closed, rather the garbage collector closes it when the last thread searching it completes. Doug --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org