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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]