lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <erickerick...@gmail.com>
Subject Re: Reloading a searcher
Date Thu, 25 Oct 2007 23:55:57 GMT
What happens if you close the writer before instantiating
a new searcher? I can't say for sure whether it matters,
but it's worth a try..

Erick

On 10/25/07, Guilherme Barile <gui@prosoma.com.br> wrote:
>
> Hello
>         I wrote a simple class to abstract searching on a text file
> (generate by a legacy system).
>
>         class MyFile { private Searcher s; private long timestamp; }
>
>         It creates a timer and checks every ten minutes if
> textfile.lastModified() is diferent from the number it cached on
> timestamp, and recreates the index. There's  a search(query) method
> which parses the query and returns an arraylist of objects.
>         My index lies on RAM, so everytime I rebuild it, i do something
> like
>
>         private void run() {
>                 File f = new File(textfile);
>
>                 if(f.lastModified() == this.timestamp) return;
>
>                 RAMDirectory idx = new RAMDirectory();
>                 IndexWriter writer = new IndexWriter(idx, new
> StandardAnalyzer
> (),true);
>                         // here I parse the text file and add the
> documents to the index
>
>                 // update the searcher and timestamp
>                 this.s = new IndexSearcher(idx);
>                 timestamp = lastModified;
>         }
>
>         Problem is: it seems the searcher is not being updated. All search
> operations occur in this class (using my own search method) accessing
> "this.s" directly
>
>         Is there any better approach for doing this (reloading the
> searcher) ?
>
> Thanks a lot
>
>
> gui
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message