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 Otis Gospodnetic <ot...@yahoo.com> on 2002/10/04 04:37:07 UTC
Re: IndexReader.open problem
This seems like a better question for lucene-user list.
Why not just deal with IndexSearcher?
Here's a sample code I wrote a while ago:
private static final String _paIndexDir =
System.getProperty("foo.index.dir");
private static long _paIndexLastMod = 0L;
private static IndexSearcher _paIndexSearcher;
private static final Analyzer _analyzer = new PorterStemAnalyzer();
....
....
try
{
// if the index has been modified since opened, re-open it.
if (IndexReader.lastModified(_paIndexDir) >=
_paIndexLastMod)
{
_paIndexLastMod = new Date().getTime();
if (_paIndexSearcher != null)
_paIndexSearcher.close();
_paIndexLastMod = new Date().getTime();
_paIndexSearcher = new IndexSearcher(_paIndexDir);
}
}
catch (IOException e)
{
_log.error("Could not open/close IndexSearcher: " +
e.getMessage());
// ...
}
_paIndexDir is an instance of String.
Otis
--- Manish Shukla <ha...@yahoo.com> wrote:
> Hi All,
>
> What is the difference between
> indexReader.open(String[] indexpaths)
>
> and
>
> indexReader.open ( Directory dir )
>
>
>
> Seems like later locks the the directory and former
> doesn't. When would one want to use one or another.
>
> We have an index which constantly changes, while we
> don't care about the documents which got added after
> the indexreader was opened we want multiple searches
> ( multithreaded and multi process ) to search through
> the index. I am wondering which is more efficient for
> us.
>
> Thanks
> Manish
>
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>