You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Guilherme Barile <gu...@prosoma.com.br> on 2007/10/25 18:10:05 UTC
Reloading a searcher
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
[ANN]VTD-XML 2.2
Posted by jimmy Zhang <cr...@comcast.net>.
XimpleWare is proud to announce the the release of version 2.2 of VTD-XML,
the next generation XML parsers/indexer/slicer/editor. This release
significantly expands VTD-XML's ability to slice, split, edit and
incrementally update the XML documents. To this end, we introduce the
concept of namespace-compensated element fragment. This release also adds
VTD+XML index writing capability to the VTD Navigator class. Other
enhancements in this release include index size pre-computation, support for
HTTP get, and some bug fixes.
To download the latest release, please go to
http://sourceforge.net/project/showfiles.php?group_id=110612.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Reloading a searcher
Posted by Erick Erickson <er...@gmail.com>.
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 <gu...@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
>
>