You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Matt Mitchell <go...@gmail.com> on 2009/12/17 16:13:30 UTC

Question about extending a response writer

Hi,

I'm pretty new solr internals, but have been experimenting with good
results... up to now!

What I'm trying to do is make it possible for the mlt docs to have their own
custom fl, separate from the main docs fl. I'm only interested in the ruby
response at this point. So the only way I've found to do this is to create a
new query response writer, which extends the ruby response writer and make a
few changes:

http://gist.github.com/258797

This class compiles fine. I put my "mlt-ruby-response-writer.jar" within my
solr-home/lib dir, and registered the response writer. Solr starts up
without errors.

... but when I run it within Solr I get an error:

class org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter
cannot access its superclass org.apache.solr.request.RubyWriter

java.lang.IllegalAccessError: class
org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter cannot
access its superclass org.apache.solr.request.RubyWriter

Anyone have an idea to what I might be doing wrong? Why would I be able to
compile, but then get a runtime error like that? Is this a classpath thing?

Oh, the error occurs when I make a request and specify the wt, which I named
"mltrb".

Thanks,
Matt

Re: Question about extending a response writer

Posted by Matt Mitchell <go...@gmail.com>.
Thanks Erik! I wasn't able to solve my problem unfortunately. I had a closer
look at the mlt component and handler. That does seem like the right place
to put it, but I can't find a way to add a custom fl for the mlt docs. It
would seem as though the response writers' writeDocList method accepts a
"fields" argument which is used for all documents. Is that the case?

I'll continue messing with this - in a less rogue way ;) and if I come up
with something useful I'd be glad to contribute it!

Matt

On Thu, Dec 17, 2009 at 1:31 PM, Erik Hatcher <er...@gmail.com>wrote:

> Matt,
>
> I'm not sure if this will help - but pull your definition of MLTRubyWriter
> outside of MLTRubyResponseWriter (look at RubyResponseWriter.java for hot is
> done there).  RubyWriter isn't public, but you're using the same package so
> it should work.
>
> Also, of course you know this, but extending the response writers for this
> sort of thing is not really the way to go.  What needs to happen is the
> MoreLikeThisComponent should be adjusted to have a way to override the
> default field list from fl.  If you build it this way, it'd be something we
> could add to Solr and support in the core, versus your unsupported rogue way
> :)
>
>        Erik
>
>
>
>
> On Dec 17, 2009, at 10:13 AM, Matt Mitchell wrote:
>
>  Hi,
>>
>> I'm pretty new solr internals, but have been experimenting with good
>> results... up to now!
>>
>> What I'm trying to do is make it possible for the mlt docs to have their
>> own
>> custom fl, separate from the main docs fl. I'm only interested in the ruby
>> response at this point. So the only way I've found to do this is to create
>> a
>> new query response writer, which extends the ruby response writer and make
>> a
>> few changes:
>>
>> http://gist.github.com/258797
>>
>> This class compiles fine. I put my "mlt-ruby-response-writer.jar" within
>> my
>> solr-home/lib dir, and registered the response writer. Solr starts up
>> without errors.
>>
>> ... but when I run it within Solr I get an error:
>>
>> class org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter
>> cannot access its superclass org.apache.solr.request.RubyWriter
>>
>> java.lang.IllegalAccessError: class
>> org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter cannot
>> access its superclass org.apache.solr.request.RubyWriter
>>
>> Anyone have an idea to what I might be doing wrong? Why would I be able to
>> compile, but then get a runtime error like that? Is this a classpath
>> thing?
>>
>> Oh, the error occurs when I make a request and specify the wt, which I
>> named
>> "mltrb".
>>
>> Thanks,
>> Matt
>>
>
>

Re: Question about extending a response writer

Posted by Erik Hatcher <er...@gmail.com>.
Matt,

I'm not sure if this will help - but pull your definition of  
MLTRubyWriter outside of MLTRubyResponseWriter (look at  
RubyResponseWriter.java for hot is done there).  RubyWriter isn't  
public, but you're using the same package so it should work.

Also, of course you know this, but extending the response writers for  
this sort of thing is not really the way to go.  What needs to happen  
is the MoreLikeThisComponent should be adjusted to have a way to  
override the default field list from fl.  If you build it this way,  
it'd be something we could add to Solr and support in the core, versus  
your unsupported rogue way :)

	Erik



On Dec 17, 2009, at 10:13 AM, Matt Mitchell wrote:

> Hi,
>
> I'm pretty new solr internals, but have been experimenting with good
> results... up to now!
>
> What I'm trying to do is make it possible for the mlt docs to have  
> their own
> custom fl, separate from the main docs fl. I'm only interested in  
> the ruby
> response at this point. So the only way I've found to do this is to  
> create a
> new query response writer, which extends the ruby response writer  
> and make a
> few changes:
>
> http://gist.github.com/258797
>
> This class compiles fine. I put my "mlt-ruby-response-writer.jar"  
> within my
> solr-home/lib dir, and registered the response writer. Solr starts up
> without errors.
>
> ... but when I run it within Solr I get an error:
>
> class org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter
> cannot access its superclass org.apache.solr.request.RubyWriter
>
> java.lang.IllegalAccessError: class
> org.apache.solr.request.MLTRubyResponseWriter$MLTRubyWriter cannot
> access its superclass org.apache.solr.request.RubyWriter
>
> Anyone have an idea to what I might be doing wrong? Why would I be  
> able to
> compile, but then get a runtime error like that? Is this a classpath  
> thing?
>
> Oh, the error occurs when I make a request and specify the wt, which  
> I named
> "mltrb".
>
> Thanks,
> Matt