You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gabriele Kahlout <ga...@mysimpatico.com> on 2011/07/10 16:53:04 UTC
Can I write to the index from within RequestHandler.handleRequestBody(..)?
Hello,
IndexWriter writer = new IndexWriter(FSDirectory.open(new
File(req.getCore().getDataDir(), "index")), req.getSchema().getAnalyzer(),
IndexWriter.MaxFieldLength.LIMITED);
updateSolrIndex(writer);
But this is what I get (I know that RequestHandler are not intended to write
updates).
HTTP Status 500 - null java.nio.channels.OverlappingFileLockException at
sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
at
sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:868) at
java.nio.channels.FileChannel.tryLock(FileChannel.java:962) at
org.apache.lucene.store.NativeFSLock.obtain(NativeFSLockFactory.java:216) at
org.apache.lucene.store.Lock.obtain(Lock.java:72) at
org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1111) at
org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:955) at
com.mysimpatico.me.indexplugins.MRequestHandler.handleRequestBody(MRequestHandler.java:97)
at
--
Regards,
K. Gabriele
--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).
If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).
Re: Can I write to the index from within RequestHandler.handleRequestBody(..)?
Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(11/07/11 4:45), Gabriele Kahlout wrote:
> On Sun, Jul 10, 2011 at 6:21 PM, Koji Sekiguchi<ko...@r.email.ne.jp> wrote:
>
>> There are such RequestHandlers. Look at CSVRequestHandler, for example.
>
>
>>
>> IndexWriter writer = new IndexWriter(FSDirectory.open(**new
>>> File(req.getCore().getDataDir(**), "index")),
>>> req.getSchema().getAnalyzer(),
>>> IndexWriter.MaxFieldLength.**LIMITED);
>>> updateSolrIndex(writer);
>>>
>>
>> Don't use your own writer for same index. Use UpdateRequestProcessor.**processAdd()
>> instead.
>>
>>
> What you seem to be suggesting is:
>
> UpdateRequestProcessorChain processorChain =
> req.getCore().getUpdateProcessingChain("WcUpdate");
> UpdateRequestProcessor processor =
> processorChain.createProcessor(req, rsp);
> try{
> RequestHandlerUtils.handleCommit(processor, params, false);
> RequestHandlerUtils.handleRollback(processor, params, false);
> }finally{
> processor.finish();
> }
>
> But this is not what I want. I want an IndexWriter instance from which I can
> get a reader, the analyzer in use, and the similarity class. If I shall
> crease a new IndexWriter for the same index, can I re-use the current one
> directly, without the UpdateRequestProcessor interface?
Technically, unless you have your own update handler that extends DirectUpdateHandler2
as it has the IndexWriter as protected member, I don't think you can do it.
koji
--
http://www.rondhuit.com/en/
Re: Can I write to the index from within RequestHandler.handleRequestBody(..)?
Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
On Sun, Jul 10, 2011 at 6:21 PM, Koji Sekiguchi <ko...@r.email.ne.jp> wrote:
> There are such RequestHandlers. Look at CSVRequestHandler, for example.
>
> IndexWriter writer = new IndexWriter(FSDirectory.open(**new
>> File(req.getCore().getDataDir(**), "index")),
>> req.getSchema().getAnalyzer(),
>> IndexWriter.MaxFieldLength.**LIMITED);
>> updateSolrIndex(writer);
>>
>
> Don't use your own writer for same index. Use UpdateRequestProcessor.**processAdd()
> instead.
>
>
What you seem to be suggesting is:
UpdateRequestProcessorChain processorChain =
req.getCore().getUpdateProcessingChain("WcUpdate");
UpdateRequestProcessor processor =
processorChain.createProcessor(req, rsp);
try{
RequestHandlerUtils.handleCommit(processor, params, false);
RequestHandlerUtils.handleRollback(processor, params, false);
}finally{
processor.finish();
}
But this is not what I want. I want an IndexWriter instance from which I can
get a reader, the analyzer in use, and the similarity class. If I shall
crease a new IndexWriter for the same index, can I re-use the current one
directly, without the UpdateRequestProcessor interface?
koji
> --
> http://www.rondhuit.com/en/
>
--
Regards,
K. Gabriele
--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).
If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).
Re: Can I write to the index from within RequestHandler.handleRequestBody(..)?
Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
There are such RequestHandlers. Look at CSVRequestHandler, for example.
> IndexWriter writer = new IndexWriter(FSDirectory.open(new
> File(req.getCore().getDataDir(), "index")), req.getSchema().getAnalyzer(),
> IndexWriter.MaxFieldLength.LIMITED);
> updateSolrIndex(writer);
Don't use your own writer for same index. Use UpdateRequestProcessor.processAdd() instead.
koji
--
http://www.rondhuit.com/en/