lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guilherme Barile <>
Subject Reloading a searcher
Date Thu, 25 Oct 2007 16:10:05 GMT
	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 
			// 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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message