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 Michael Wechner <mi...@wyona.com> on 2011/12/13 19:36:23 UTC
How to use setWriteLockTimeout(long) when write.lock already exists
Hi
According to
http://www.gossamer-threads.com/lists/lucene/java-dev/37421
one cannot overwrite the default write lock timeout of 1000ms once a
write.lock already exists (for example inside a multi-threaded
web-application), because in order to use the method
setWriteLockTimeout(long) one would have to
first create an instance of IndexWriter, but because write.lock already
exists the creation will throw a LockObtainFailedException and hence
once does not get an instance.
In the link above "Mike" is mentioned that he will create a Jira issue,
but it's not clear to me if it ever got created
and/or that somebody tried to improve this. Any idea?
Just as a suggestions, but I think it would be nice if one could create
an IndexWriter instance without actually opening the index in the first
place, but rather something like:
IndexWriter iWriter = new IndexWriter();
iWriter.setDirectory(...);
iWriter.setAnalyzer(....);
iWriter.setWriteLockTimeout(75);
iWriter.open(); // or iWriter.checkout();
// do something with the index....
iWriter.close();
WDYT?
Thanks
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How to use setWriteLockTimeout(long) when write.lock already
exists
Posted by Michael Wechner <mi...@wyona.com>.
Am 13.12.11 19:36, schrieb Michael Wechner:
> Hi
>
> According to
>
> http://www.gossamer-threads.com/lists/lucene/java-dev/37421
>
> one cannot overwrite the default write lock timeout of 1000ms once a
> write.lock already exists (for example inside a multi-threaded
> web-application), because in order to use the method
> setWriteLockTimeout(long) one would have to
> first create an instance of IndexWriter, but because write.lock
> already exists the creation will throw a LockObtainFailedException and
> hence once does not get an instance.
>
> In the link above "Mike" is mentioned that he will create a Jira
> issue, but it's not clear to me if it ever got created
> and/or that somebody tried to improve this. Any idea?
I think I have found the JIRA issue mentioned in the above email thread:
https://issues.apache.org/jira/browse/LUCENE-621
and according to the test class one can set the timeout ahead of
initializing the IndexWriter
IndexWriter.setDefaultWriteLockTimeout(2000);
IndexWriter.setDefaultCommitLockTimeout(2000);
IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
This seems to work fine.
Thanks
Michael
>
> Just as a suggestions, but I think it would be nice if one could
> create an IndexWriter instance without actually opening the index in
> the first place, but rather something like:
>
> IndexWriter iWriter = new IndexWriter();
> iWriter.setDirectory(...);
> iWriter.setAnalyzer(....);
> iWriter.setWriteLockTimeout(75);
> iWriter.open(); // or iWriter.checkout();
> // do something with the index....
> iWriter.close();
>
> WDYT?
>
> Thanks
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: highlighter: how can I get locations of fragments?
Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: highlighter: how can I get locations of fragments?
: References: <4E...@wyona.com>
: In-Reply-To: <4E...@wyona.com>
https://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists
When starting a new discussion on a mailing list, please do not reply to
an existing message, instead start a fresh email. Even if you change the
subject line of your email, other mail headers still track which thread
you replied to and your question is "hidden" in that thread and gets less
attention. It makes following discussions in the mailing list archives
particularly difficult.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
highlighter: how can I get locations of fragments?
Posted by Ilya Zavorin <iz...@caci.com>.
I know how to get relevant highlighted fragments together with some surrounding text using Lucene highlighter, namely, using
Highlighter highlighter = new Highlighter(scorer);
String[] fragments = highlighter.getBestFragments(stream, fieldContents, fragmentNumber);
But can I instead get pointers to these fragments in the original contents? In other words, I need to know where these fragments start and, if possible, end.
Thanks,
Ilya Zavorin
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org