Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 15489 invoked from network); 19 Aug 2003 21:41:33 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 19 Aug 2003 21:41:33 -0000 Received: (qmail 5738 invoked by uid 97); 19 Aug 2003 21:16:00 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@nagoya.betaversion.org Received: (qmail 5731 invoked from network); 19 Aug 2003 21:16:00 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 19 Aug 2003 21:16:00 -0000 Received: (qmail 11675 invoked by uid 500); 19 Aug 2003 20:59:44 -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 11100 invoked from network); 19 Aug 2003 20:59:33 -0000 Received: from h011.c007.snv.cp.net (HELO c007.snv.cp.net) (209.228.33.239) by daedalus.apache.org with SMTP; 19 Aug 2003 20:59:33 -0000 Received: (cpmta 1182 invoked from network); 19 Aug 2003 09:59:30 -0700 Received: from 209.228.33.230 (HELO mail.bayt.net.criticalpath.net) by smtp.bayt.net (209.228.33.239) with SMTP; 19 Aug 2003 09:59:30 -0700 X-Sent: 19 Aug 2003 16:59:30 GMT Received: from [195.14.135.107] by mail.bayt.net with HTTP; Tue, 19 Aug 2003 09:59:29 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: lucene-user@jakarta.apache.org From: "Nader Henein" Subject: Re: Multi-Threading X-Sent-From: nsh@bayt.net Date: Tue, 19 Aug 2003 09:59:29 -0700 (PDT) X-Mailer: Web Mail 5.5.0-3_sol28 Message-Id: <20030819095930.27040.h002.c007.wm@mail.bayt.net.criticalpath.net> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Why do you have concurency problems? are you trying to have each user initiate the indexing himself? because that will create issues, how about you put all the new files you want to index in a directory and then have a schedule procedure on the webserver run the lucene indexer on that directory, our application hasn't had any concurrency problems at all, because we index based on a pull system, rather than the user puching documents to the indexer. I hope I understood your problem correctly, so that the answer is useful Nader On Tue, 19 Aug 2003 12:55:09 +0200, Damien Lust wrote: > > Hello, > > I developed an Client-Server application on the web, > with a search > module using Lucene. In the same application, the users > can index new > text. > > So, multiple sessions can acces to the Index and > concurrences problems > can be possible. > > I used Threads in Java. Is it the best solutions? > > I call : > > IndexFiles indexFiles = new IndexFiles(); > indexFiles.run(); > > Here you are an extract of my code. > > Thanks. > > public class IndexFiles extends Thread{ > public IndexFiles(){ > } > > public void run(){ > > SynchronizedIndexWriter.insertDocument(currentIndexDocument(),"tmp/ > IndexPath",new MainAnalyser()); > } > > } > > > > public class SynchronizedIndexWriter { > > static synchronized void > insertDocument(IndexDocument > document,String indexLocValue,Analyzer analyzerValue){ > File f=new File(indexLocValue); > if (f.exists()) > addDocumentToIndex(document,indexLocValue,analyzerValue,false); > else > addDocumentToIndex(document,indexLocValue,analyzerValue,true); > } > > > static synchronized void > addDocumentToIndex(IndexDocument > document,String indexLocValue,Analyzer > analyzerValue,boolean > createNewIndex){ > try{ > IndexWriter indexWriter = new > IndexWriter(indexLocValue,analyzerValue,createNewIndex); > > indexWriter.addDocument(document.getDocument()); > indexWriter.optimize(); > indexWriter.close(); > } > catch(IOException io){ > // If IndexWrite don't know write on index because > it's locked, > recall of the function > => It's not very safe > > addDocumentToIndex(document,indexLocValue,analyzerValue,createNewIndex); > } > catch(Exception e){ > > } > > } > } The information contained above is proprietary to BAYT.COM and confidential. --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org