lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: IndexReader.delete problem
Date Wed, 21 May 2003 15:55:49 GMT
In your search code detect that the index changed and get a new
IndexSearcher.

Otis

--- Doug Kirk <doug@dougandalli.com> wrote:
> > Perhaps you are using 'new IndexWriter(path, analyzer, true)'
> rather
> > than 'new IndexWriter(path, analyzer, false)'?
> 
> Yes, that is what was happening.  (Big Thanks!)
> 
> Here's a new problem, though: after changing the above to 'new 
> IndexWriter(fsdirectory, analyzer, false)', my updated document no 
> longer shows up in searches. No exception is being thrown during the 
> entire updateObject() process.
> 
> The logic is:
> 
> void updateObject(Object bean)  throws IOException, IndexException {
>      deleteObject(bean);
>      insertObject(bean);
> }
> 
> void insertObject(Object bean)  throws IOException, IndexException {
>      IndexWriter writer = null;
>      try {
>          writer = getIndexWriter(false);    // false == create; uses 
> previously cached FSDirectory and StandardAnalyzer
>          Document doc = createDocument(bean);      //  subclass impl
>          writer.addDocument(doc);
>      }
>      catch (IOException & IndexException & Exception) { ... }      //
>  
> shortened for brevity
>      finally {
>           if (writer != null) writer.close();
>      }
> }
> 
> void deleteObject(Object bean) throws IOException, IndexException
> {
>      IndexReader reader = null;
>      try {
>          reader = getIndexReader();    //  returns 
> IndexReader.open(cached FSDirectory)
>          reader.delete(getPrimaryTerm(bean));    //  subclass impl
>      }
>      catch (IOException & IndexException & Exception) { ... }     // 
> shortened for brevity
>      finally {
>          if (reader != null) {
>              try {
>                  reader.close();
>              }
>              catch (IOException ignored) {
>              }
>          }
>      }
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message