Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 44610 invoked from network); 3 Feb 2008 18:09:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Feb 2008 18:09:08 -0000 Received: (qmail 72578 invoked by uid 500); 3 Feb 2008 18:08:54 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 72543 invoked by uid 500); 3 Feb 2008 18:08:54 -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 72532 invoked by uid 99); 3 Feb 2008 18:08:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2008 10:08:54 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of markrmiller@gmail.com designates 72.14.220.155 as permitted sender) Received: from [72.14.220.155] (HELO fg-out-1718.google.com) (72.14.220.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2008 18:08:26 +0000 Received: by fg-out-1718.google.com with SMTP id d23so2241576fga.27 for ; Sun, 03 Feb 2008 10:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=C5gPPD3EhJGAP7eXhE+8c+wbsp2NdzV7b5KhTIFE+a0=; b=hltNAXQymPzXhFswX7F/svkBovqXC+npnPQIAqGreDRFfyXV8V/X87/F6hld2cuGmtTOImYQX2vAshooRYSYUUl4bHRw7GPYoDRQbdouM58Hxfx8D02xnkFaTQaIaiwc/r6q1Zwy4Be/8Pq7I6DbMkl1MT7TCvWzJzyfG9EJbRA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=gWGor+JZLhVw5CgtRoETzqq34XGPTQcHGejC4rrEGej1qi+s/l5zhj/ep78IrwmjpwLbDxhawulO4s/m+07zuRUCcPgqV7PB4mzTK+tbTz7TRVEHxO9veza7zyuIvxRsqESs6xuia4W5g721BxWtglu7lq7Sr4flmf3KaIF99rs= Received: by 10.82.172.10 with SMTP id u10mr11264458bue.14.1202062108147; Sun, 03 Feb 2008 10:08:28 -0800 (PST) Received: from ?192.168.1.118? ( [216.66.119.110]) by mx.google.com with ESMTPS id u14sm5018841gvf.1.2008.02.03.10.08.25 (version=SSLv3 cipher=RC4-MD5); Sun, 03 Feb 2008 10:08:27 -0800 (PST) Message-ID: <47A60308.4040300@gmail.com> Date: Sun, 03 Feb 2008 13:08:08 -0500 From: Mark Miller User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: Concurrent Indexing + Searching References: <15234463.post@talk.nabble.com> <15255394.post@talk.nabble.com> In-Reply-To: <15255394.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org You are correct that autocommit=false means that docs will be in the index before the last thread releases its concurrent hold on a Writer, *but because IndexAccessor controls* *when the IndexSearchers are reopened*, those docs will still not be visible until the last thread holding a Writer releases it...that is when the reopening of Searchers occurs as well as when the Writer is closed. - Mark ajay_garg wrote: > Hi. Sorry if I seem a stranger in this thread, but there is something that I > can't resist clearing myself on. > > Mark, you say that the additional documents added to a index, won't show up > until the # of threads accessing the index hits 0; and subsequently the > indexwriter instance is closed. > > But I suppose that the autocommit=true, asserts that all flushed (Added) > documents are immediately committed ( and hence visible ) in the index, and > no explicit cclosing ( releasiing ) of the Indexwriter instance is required. > ( Of course, re-opening an IndexSearcher instance is required ). > > Am I being dumb ? > > Looking eagerly for you to shed some light on my doubt. > > Thanks > Ajay Garg > > > codetester wrote: > >> Hi All, >> >> A newbie out here.... I am using lucene 2.3.0. I need to use lucene to >> perform live searching and indexing. To achieve that, I tried the >> following >> >> FSDirectory directory = FSDirectory.getDirectory(location); >> IndexReader reader = IndexReader.open(directory ); >> IndexWriter writer = new IndexWriter(directory , new SimpleAnalyzer(), >> true); // <- I want to recreate the index every time >> IndexSearcher searcher = new IndexSearcher( reader ); >> >> For Searching, I have the following code >> QueryParser queryParser = new QueryParser("xyz", new StandardAnalyzer()); >> Hits hits = searcher .search(queryParser.parse(displayName + "*")); >> >> And for adding records, I have the following code >> // Create doc object >> writer.addDocument(doc); >> >> IndexReader newIndexReader = reader.reopen() ; >> if ( newIndexReader != reader ) { >> reader.close() ; >> } >> reader = newIndexReader ; >> searcher.close() ; >> searcher = new IndexSearcher(reader ); >> >> So the issues that I face are >> >> 1) The addition of new record is not reflected in the search ( even though >> I have reinited IndexSearcher ) >> >> 2) Obviously, the add record code is not thread safe. I am trying to close >> and update the reference to IndexSearcher object. I could add a sync >> block, but the bigger question would be that what is the ideal way to >> achieve this case where I need to add and search record real-time ? >> >> Thanks ! >> >> >> >> >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org