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 vivek sar <vi...@gmail.com> on 2009/06/10 03:05:30 UTC

Servlet filter for Solr

Hi,

  I've to intercept every request to solr (search and update) and log
some performance numbers. In order to do so I tried a Servlet filter
and added this to Solr's web.xml,

          <filter>
                <filter-name>IndexFilter</filter-name>

<filter-class>com.xxx.index.filter.IndexRequestFilter</filter-class>
                <init-param>
                        <param-name>test-param</param-name>
                        <param-value>This parameter is for
testing.</param-value>
                </init-param>
        </filter>
        <filter-mapping>
                <filter-name>IndexFilter</filter-name>
               <!--<url-pattern>/*</url-pattern> -->
             <servlet-name>SolrUpdate</servlet-name>
             <servlet-name>SolrServer</servlet-name>
        </filter-mapping>

but, this doesn't seem to be working. Couple of questions,

1) What's wrong with my web.xml setting?
2) Is there any easier way to intercept calls to Solr without changing
its web.xml? Basically can I just change the solrconfig.xml to do so
(beside requesthandlers) so I don't have to customize the solr.war?

Thanks,
-vivek

Re: Servlet filter for Solr

Posted by vivek sar <vi...@gmail.com>.
I've tried both "url-pattern" (/*) and servlet-name in the filter
mapping , but none of it seem to intercept the call. If I put (/*)
only up to /solr gets intercepted. Since, I'm using multicore - calls
like /solr/core0 don't get intercepted. I want both select and update
to be monitored. Any ideas?

Thanks,
-vivek

2009/6/9 Noble Paul നോബിള്‍  नोब्ळ् <no...@corp.aol.com>:
> if you wish to intercept "read" calls ,a filter is the only way.
>
>
> On Wed, Jun 10, 2009 at 6:35 AM, vivek sar<vi...@gmail.com> wrote:
>> Hi,
>>
>>  I've to intercept every request to solr (search and update) and log
>> some performance numbers. In order to do so I tried a Servlet filter
>> and added this to Solr's web.xml,
>>
>>          <filter>
>>                <filter-name>IndexFilter</filter-name>
>>
>> <filter-class>com.xxx.index.filter.IndexRequestFilter</filter-class>
>>                <init-param>
>>                        <param-name>test-param</param-name>
>>                        <param-value>This parameter is for
>> testing.</param-value>
>>                </init-param>
>>        </filter>
>>        <filter-mapping>
>>                <filter-name>IndexFilter</filter-name>
>>               <!--<url-pattern>/*</url-pattern> -->
>>             <servlet-name>SolrUpdate</servlet-name>
>>             <servlet-name>SolrServer</servlet-name>
>
> I guess you canot put servlets in the filter mapping
>>        </filter-mapping>
>>
>> but, this doesn't seem to be working. Couple of questions,
>>
>> 1) What's wrong with my web.xml setting?
>> 2) Is there any easier way to intercept calls to Solr without changing
>> its web.xml? Basically can I just change the solrconfig.xml to do so
>> (beside requesthandlers) so I don't have to customize the solr.war?
>>
>> Thanks,
>> -vivek
>>
>
>
>
> --
> -----------------------------------------------------
> Noble Paul | Principal Engineer| AOL | http://aol.com
>

Re: Servlet filter for Solr

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>.
if you wish to intercept "read" calls ,a filter is the only way.


On Wed, Jun 10, 2009 at 6:35 AM, vivek sar<vi...@gmail.com> wrote:
> Hi,
>
>  I've to intercept every request to solr (search and update) and log
> some performance numbers. In order to do so I tried a Servlet filter
> and added this to Solr's web.xml,
>
>          <filter>
>                <filter-name>IndexFilter</filter-name>
>
> <filter-class>com.xxx.index.filter.IndexRequestFilter</filter-class>
>                <init-param>
>                        <param-name>test-param</param-name>
>                        <param-value>This parameter is for
> testing.</param-value>
>                </init-param>
>        </filter>
>        <filter-mapping>
>                <filter-name>IndexFilter</filter-name>
>               <!--<url-pattern>/*</url-pattern> -->
>             <servlet-name>SolrUpdate</servlet-name>
>             <servlet-name>SolrServer</servlet-name>

I guess you canot put servlets in the filter mapping
>        </filter-mapping>
>
> but, this doesn't seem to be working. Couple of questions,
>
> 1) What's wrong with my web.xml setting?
> 2) Is there any easier way to intercept calls to Solr without changing
> its web.xml? Basically can I just change the solrconfig.xml to do so
> (beside requesthandlers) so I don't have to customize the solr.war?
>
> Thanks,
> -vivek
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com