lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nader Henein" <nader.hen...@bayt.net>
Subject Re: Multi-Threading
Date Tue, 19 Aug 2003 16:59:29 GMT
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.

Mime
View raw message