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 elmerfudd <na...@012.net.il> on 2013/12/26 15:59:39 UTC

Chaining plugins

I would like to develope a search handler that is doing some logic and then
just sends the query to the default search handler so the results will be
generated there. 
It's like it is a transparent plugin and the data will only go through it.

How can this be achieved .
thanks ahead :) 



--
View this message in context: http://lucene.472066.n3.nabble.com/Chaining-plugins-tp4108239.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Chaining plugins

Posted by elmerfudd <na...@012.net.il>.
If I want to do it? do i have to work with the source code version of solr?
if so, where is the default search handler located?



--
View this message in context: http://lucene.472066.n3.nabble.com/Chaining-plugins-tp4108239p4109102.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Chaining plugins

Posted by Liu Bo <di...@gmail.com>.
Hi

I've done similar things as paul.

what I do is extending the default QueryComponent and overwrite the
preparing method,

then I just change the solrparams according to our logic and then call
super.prepare(). Then replace the default QueryComponent with it in my
search/query handler.

In this way, nothing of solr default behavior is touched. I think you can
do your logic in prepare method, and then let solr proceed the search.

I've tested it along with other components in both single solr node and
solrcloud. It works fine.

Hope it helps

Cheers

Bold



On 31 December 2013 06:03, Chris Hostetter <ho...@fucit.org> wrote:

>
> You don't need to write your own handler.
>
> See the previpous comment about implementing a SearchComponent -- you can
> check for the params in your prepare() method and do whatever side effects
> you want, then register your custom component and hook it into the
> component chain of whatever handler configuration you want (either using
> the "components" <arr> or by specifying it as a "first-components"...
>
>
> https://cwiki.apache.org/confluence/display/solr/RequestHandlers+and+SearchComponents+in+SolrConfig
>
> : I want to save the query into a file when a user is changing a parameter
> in
> : the query, lets say he adds "logTofile=1" then the searchHandler will
> : provide the same result as without this parameter, but in the background
> it
> : will do some logic(ex. save the query to file) .
> : But I dont want to touch solr source code, all I want is to add code(like
> : plugin). if i understand it right I want to write my own search handler
> , do
> : some logic , then pass the data to solr default search handler.
>
>
>
>
> -Hoss
> http://www.lucidworks.com/
>



-- 
All the best

Liu Bo

Re: Chaining plugins

Posted by Chris Hostetter <ho...@fucit.org>.
You don't need to write your own handler.

See the previpous comment about implementing a SearchComponent -- you can 
check for the params in your prepare() method and do whatever side effects 
you want, then register your custom component and hook it into the 
component chain of whatever handler configuration you want (either using 
the "components" <arr> or by specifying it as a "first-components"...

https://cwiki.apache.org/confluence/display/solr/RequestHandlers+and+SearchComponents+in+SolrConfig

: I want to save the query into a file when a user is changing a parameter in
: the query, lets say he adds "logTofile=1" then the searchHandler will
: provide the same result as without this parameter, but in the background it
: will do some logic(ex. save the query to file) .
: But I dont want to touch solr source code, all I want is to add code(like
: plugin). if i understand it right I want to write my own search handler , do
: some logic , then pass the data to solr default search handler.




-Hoss
http://www.lucidworks.com/

Re: Chaining plugins

Posted by elmerfudd <na...@012.net.il>.
I will make it clear.
I want to save the query into a file when a user is changing a parameter in
the query, lets say he adds "logTofile=1" then the searchHandler will
provide the same result as without this parameter, but in the background it
will do some logic(ex. save the query to file) .
But I dont want to touch solr source code, all I want is to add code(like
plugin). if i understand it right I want to write my own search handler , do
some logic , then pass the data to solr default search handler.

how do i accomplish this?



--
View this message in context: http://lucene.472066.n3.nabble.com/Chaining-plugins-tp4108239p4108662.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Chaining plugins

Posted by Kydryavtsev Andrey <we...@yandex.ru>.
If I get elmer fudd's question correct, he needs something like creating his own component which will extends SearchComponent and do some logic in prepare method - change input request params probably. Then register this component in solrconfig and set it's for default search handler just before query component like:

    <arr name="components">
      <str>newComponentName</str>
      <str>query</str>
      <str>facet</str>
      <str>mlt</str>
      <str>highlight</str>
      <str>debug</str>
    </arr>

Lucene's search in query component will be executed with modified parameters.

26.12.2013, 20:55, "Paul Libbrecht" <pa...@hoplahup.net>:
> I have subclassed the query component to do so.
> Using params, you can get almost everything thinkable that is not too much documented.
>
> paul
>
> On 26 déc. 2013, at 15:59, elmerfudd <na...@012.net.il> wrote:
>
>>  I would like to develope a search handler that is doing some logic and then
>>  just sends the query to the default search handler so the results will be
>>  generated there.
>>  It's like it is a transparent plugin and the data will only go through it.
>>
>>  How can this be achieved .
>>  thanks ahead :)
>>
>>  --
>>  View this message in context: http://lucene.472066.n3.nabble.com/Chaining-plugins-tp4108239.html
>>  Sent from the Solr - User mailing list archive at Nabble.com.

Re: Chaining plugins

Posted by Paul Libbrecht <pa...@hoplahup.net>.
I have subclassed the query component to do so.
Using params, you can get almost everything thinkable that is not too much documented.

paul

On 26 déc. 2013, at 15:59, elmerfudd <na...@012.net.il> wrote:

> I would like to develope a search handler that is doing some logic and then
> just sends the query to the default search handler so the results will be
> generated there. 
> It's like it is a transparent plugin and the data will only go through it.
> 
> How can this be achieved .
> thanks ahead :) 
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Chaining-plugins-tp4108239.html
> Sent from the Solr - User mailing list archive at Nabble.com.