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 Umar Shah <um...@wisdomtap.com> on 2008/05/12 10:59:58 UTC

help for preprocessing the query

Hi,

Due some requirement I need to transform the user queries before passing it
to the standard handler in Solr,  can anyone suggest me the best way to do
this.

I will need to use a transfomation class that would provide functions to
process the input query 'qIn' and transform it to the resultant query 'qOut'
and then pass it to solr handler as if qOut were the original user query.

thanks in anticipation,
-umar

Re: help for preprocessing the query

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
Shalin Shekhar Mangar write:
> ServletRequest and ServletRequestWrapper are part of the Java servlet-api
> (not Solr). Basically, Koji is hinting at writing a ServletFilter
> implementation (again using servlet-api) and creating a wrapper
> ServletRequest which modifies the underlying request params which can then
> be used by Solr.
>   
Right.

Koji


Re: help for preprocessing the query

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
http://java.sun.com/products/servlet/Filters.html
this is a servlet container feature
BTW , this may not be a right forum for this topic.
--Noble

On Tue, May 13, 2008 at 5:04 PM, Umar Shah <um...@wisdomtap.com> wrote:
> On Tue, May 13, 2008 at 4:39 PM, Shalin Shekhar Mangar <
>  shalinmangar@gmail.com> wrote:
>
>  > Did you put a filter-mapping in web.xml?
>
>
>  no,
>  I just did that and it seems to be working...
>
>  what is filter-mapping required for?
>
>
>
>
>  >
>  > On Tue, May 13, 2008 at 4:20 PM, Umar Shah <um...@wisdomtap.com> wrote:
>  >
>  > > On Mon, May 12, 2008 at 10:30 PM, Shalin Shekhar Mangar <
>  > > shalinmangar@gmail.com> wrote:
>  > >
>  > > > You'll *not* write a servlet. You'll write implement the Filter
>  > > interface
>  > > >
>  > http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html
>  > > >
>  > > > In the doFilter method, you'll create a ServletRequestWrapper which
>  > > > changes
>  > > > the incoming param. Then you'll call chain.doFilter with the new
>  > request
>  > > > object. You'll need to add this filter before the SolrRequestFilter in
>  > > > Solr's web.xml
>  > >
>  > > I created a CustomFilter that would dump the request contents to a file,
>  > > I created the jar and added it to the solr.war in WEB_INF/lib folder
>  > > I edited the web.xml in the same folder to include the following lines:
>  > > <filter>
>  > >    <filter-name>CustomFilter</filter-name>
>  > >    <filter-class>(packagename).CustomFilter</filter-class>
>  > >  </filter>
>  > >
>  > > where CustomFilter is the name of the class extending
>  > > javax.servlet.Filter.
>  > >
>  > > I don't see anything in the contents of the file..
>  > >
>  > > thanks for your help
>  > > -umar
>  > >
>  > >
>  > > >
>  > > > Look at
>  > > >
>  > > >
>  > >
>  > http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
>  > > > more details.
>  > > >
>  > > > On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com> wrote:
>  > > >
>  > > > > On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
>  > > > > shalinmangar@gmail.com> wrote:
>  > > > >
>  > > > > > ServletRequest and ServletRequestWrapper are part of the Java
>  > > > > servlet-api
>  > > > > > (not Solr). Basically, Koji is hinting at writing a ServletFilter
>  > > > > > implementation (again using servlet-api) and creating a wrapper
>  > > > > > ServletRequest which modifies the underlying request params which
>  > > can
>  > > > > then
>  > > > > > be used by Solr.
>  > > > > >
>  > > > >
>  > > > > sorry for the silly question, basically i am new to servlets.
>  > > > > Now If my understanding is right , I will need to create a
>  > > > servlet/wrapper
>  > > > > that would listen the user facing queries and then pass the
>  > processed
>  > > > text
>  > > > > to solr request handler and I need to pack this servlet class file
>  > > into
>  > > > > Solr
>  > > > > war file.
>  > > > >
>  > > > > But How would I ensure that my servlet is called instead of solr
>  > > request
>  > > > > handler?
>  > > > >
>  > > > >
>  > > > > > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com>
>  > > wrote:
>  > > > > >
>  > > > > > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <
>  > > koji@r.email.ne.jp>
>  > > > > > > wrote:
>  > > > > > >
>  > > > > > > > Hi Umar,
>  > > > > > > >
>  > > > > > > > You may be able to preprocess your request parameter in your
>  > > > > > > > servlet filter. In the doFilter() method, you do:
>  > > > > > > >
>  > > > > > > > ServletRequest myRequest = new MyServletRequestWrapper(
>  > request
>  > > );
>  > > > > > >
>  > > > > > >
>  > > > > > > Thanks for your response,
>  > > > > > >
>  > > > > > > Where is the ServletRequest class , I am using Solr 1.3 trunk
>  > code
>  > > > > > > found SolrServletm, butit is depricated, which class can I use
>  > > > instead
>  > > > > > of
>  > > > > > > SolrRequest in 1.3 codebase?
>  > > > > > >
>  > > > > > >
>  > > > > > > I also tried overloading Standard request handler , How do I re
>  > > > write
>  > > > > > > queryparams there?
>  > > > > > >
>  > > > > > > Can you point me to some documentation?
>  > > > > > >
>  > > > > > >
>  > > > > > > >   :
>  > > > > > > > chain.doFilter( myRequest, response );
>  > > > > > > >
>  > > > > > > > And you have MyServletRequestWrapper that extends
>  > > > > > ServletRequestWrapper.
>  > > > > > > > Then you can get|set q* parameters through getParameter()
>  > > method.
>  > > > > > > >
>  > > > > > > > Hope this helps,
>  > > > > > > >
>  > > > > > > > Koji
>  > > > > > > >
>  > > > > > > >
>  > > > > > > >
>  > > > > > > > Umar Shah wrote:
>  > > > > > > >
>  > > > > > > > > Hi,
>  > > > > > > > >
>  > > > > > > > > Due some requirement I need to transform the user queries
>  > > before
>  > > > > > > passing
>  > > > > > > > > it
>  > > > > > > > > to the standard handler in Solr,  can anyone suggest me the
>  > > best
>  > > > > way
>  > > > > > > to
>  > > > > > > > > do
>  > > > > > > > > this.
>  > > > > > > > >
>  > > > > > > > > I will need to use a transfomation class that would provide
>  > > > > > functions
>  > > > > > > to
>  > > > > > > > > process the input query 'qIn' and transform it to the
>  > > resultant
>  > > > > > query
>  > > > > > > > > 'qOut'
>  > > > > > > > > and then pass it to solr handler as if qOut were the
>  > original
>  > > > user
>  > > > > > > > > query.
>  > > > > > > > >
>  > > > > > > > > thanks in anticipation,
>  > > > > > > > > -umar
>  > > > > > > > >
>  > > > > > > > >
>  > > > > > > > >
>  > > > > > > >
>  > > > > > > >
>  > > > > > >
>  > > > > >
>  > > > > >
>  > > > > >
>  > > > > > --
>  > > > > > Regards,
>  > > > > > Shalin Shekhar Mangar.
>  > > > > >
>  > > > >
>  > > >
>  > > >
>  > > >
>  > > > --
>  > > > Regards,
>  > > > Shalin Shekhar Mangar.
>  > > >
>  > >
>  >
>  >
>  >
>  > --
>  > Regards,
>  > Shalin Shekhar Mangar.
>  >
>



-- 
--Noble Paul

Re: help for preprocessing the query

Posted by Umar Shah <um...@wisdomtap.com>.
On Tue, May 13, 2008 at 5:04 PM, Umar Shah <um...@wisdomtap.com> wrote:

>
>
>
>
> On Tue, May 13, 2008 at 4:39 PM, Shalin Shekhar Mangar <
> shalinmangar@gmail.com> wrote:
>
>> Did you put a filter-mapping in web.xml?
>
>
> no,
> I just did that and it seems to be working...
>

thanks for all the help folks, this community really ROCKS!!
I just implemented my filter successfully... and in doing so also got
introduced to the servlet world.


P.S: I wouldn't have asked unrelated questions here had i been able to
discern the difference.

thanks again.




>
> what is filter-mapping required for?
>
>
>>
>> On Tue, May 13, 2008 at 4:20 PM, Umar Shah <um...@wisdomtap.com> wrote:
>>
>> > On Mon, May 12, 2008 at 10:30 PM, Shalin Shekhar Mangar <
>> > shalinmangar@gmail.com> wrote:
>> >
>> > > You'll *not* write a servlet. You'll write implement the Filter
>> > interface
>> > >
>> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html
>> > >
>> > > In the doFilter method, you'll create a ServletRequestWrapper which
>> > > changes
>> > > the incoming param. Then you'll call chain.doFilter with the new
>> request
>> > > object. You'll need to add this filter before the SolrRequestFilter in
>> > > Solr's web.xml
>> >
>> > I created a CustomFilter that would dump the request contents to a file,
>> > I created the jar and added it to the solr.war in WEB_INF/lib folder
>> > I edited the web.xml in the same folder to include the following lines:
>> > <filter>
>> >    <filter-name>CustomFilter</filter-name>
>> >    <filter-class>(packagename).CustomFilter</filter-class>
>> >  </filter>
>> >
>> > where CustomFilter is the name of the class extending
>> > javax.servlet.Filter.
>> >
>> > I don't see anything in the contents of the file..
>> >
>> > thanks for your help
>> > -umar
>> >
>> >
>> > >
>> > > Look at
>> > >
>> > >
>> >
>> http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
>> > > more details.
>> > >
>> > > On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com>
>> wrote:
>> > >
>> > > > On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
>> > > > shalinmangar@gmail.com> wrote:
>> > > >
>> > > > > ServletRequest and ServletRequestWrapper are part of the Java
>> > > > servlet-api
>> > > > > (not Solr). Basically, Koji is hinting at writing a ServletFilter
>> > > > > implementation (again using servlet-api) and creating a wrapper
>> > > > > ServletRequest which modifies the underlying request params which
>> > can
>> > > > then
>> > > > > be used by Solr.
>> > > > >
>> > > >
>> > > > sorry for the silly question, basically i am new to servlets.
>> > > > Now If my understanding is right , I will need to create a
>> > > servlet/wrapper
>> > > > that would listen the user facing queries and then pass the
>> processed
>> > > text
>> > > > to solr request handler and I need to pack this servlet class file
>> > into
>> > > > Solr
>> > > > war file.
>> > > >
>> > > > But How would I ensure that my servlet is called instead of solr
>> > request
>> > > > handler?
>> > > >
>> > > >
>> > > > > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com>
>> > wrote:
>> > > > >
>> > > > > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <
>> > koji@r.email.ne.jp>
>> > > > > > wrote:
>> > > > > >
>> > > > > > > Hi Umar,
>> > > > > > >
>> > > > > > > You may be able to preprocess your request parameter in your
>> > > > > > > servlet filter. In the doFilter() method, you do:
>> > > > > > >
>> > > > > > > ServletRequest myRequest = new MyServletRequestWrapper(
>> request
>> > );
>> > > > > >
>> > > > > >
>> > > > > > Thanks for your response,
>> > > > > >
>> > > > > > Where is the ServletRequest class , I am using Solr 1.3 trunk
>> code
>> > > > > > found SolrServletm, butit is depricated, which class can I use
>> > > instead
>> > > > > of
>> > > > > > SolrRequest in 1.3 codebase?
>> > > > > >
>> > > > > >
>> > > > > > I also tried overloading Standard request handler , How do I re
>> > > write
>> > > > > > queryparams there?
>> > > > > >
>> > > > > > Can you point me to some documentation?
>> > > > > >
>> > > > > >
>> > > > > > >   :
>> > > > > > > chain.doFilter( myRequest, response );
>> > > > > > >
>> > > > > > > And you have MyServletRequestWrapper that extends
>> > > > > ServletRequestWrapper.
>> > > > > > > Then you can get|set q* parameters through getParameter()
>> > method.
>> > > > > > >
>> > > > > > > Hope this helps,
>> > > > > > >
>> > > > > > > Koji
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > > > Umar Shah wrote:
>> > > > > > >
>> > > > > > > > Hi,
>> > > > > > > >
>> > > > > > > > Due some requirement I need to transform the user queries
>> > before
>> > > > > > passing
>> > > > > > > > it
>> > > > > > > > to the standard handler in Solr,  can anyone suggest me the
>> > best
>> > > > way
>> > > > > > to
>> > > > > > > > do
>> > > > > > > > this.
>> > > > > > > >
>> > > > > > > > I will need to use a transfomation class that would provide
>> > > > > functions
>> > > > > > to
>> > > > > > > > process the input query 'qIn' and transform it to the
>> > resultant
>> > > > > query
>> > > > > > > > 'qOut'
>> > > > > > > > and then pass it to solr handler as if qOut were the
>> original
>> > > user
>> > > > > > > > query.
>> > > > > > > >
>> > > > > > > > thanks in anticipation,
>> > > > > > > > -umar
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Regards,
>> > > > > Shalin Shekhar Mangar.
>> > > > >
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Regards,
>> > > Shalin Shekhar Mangar.
>> > >
>> >
>>
>>
>>
>> --
>> Regards,
>> Shalin Shekhar Mangar.
>>
>
>

Re: help for preprocessing the query

Posted by Umar Shah <um...@wisdomtap.com>.
On Tue, May 13, 2008 at 4:39 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> Did you put a filter-mapping in web.xml?


no,
I just did that and it seems to be working...

what is filter-mapping required for?


>
> On Tue, May 13, 2008 at 4:20 PM, Umar Shah <um...@wisdomtap.com> wrote:
>
> > On Mon, May 12, 2008 at 10:30 PM, Shalin Shekhar Mangar <
> > shalinmangar@gmail.com> wrote:
> >
> > > You'll *not* write a servlet. You'll write implement the Filter
> > interface
> > >
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html
> > >
> > > In the doFilter method, you'll create a ServletRequestWrapper which
> > > changes
> > > the incoming param. Then you'll call chain.doFilter with the new
> request
> > > object. You'll need to add this filter before the SolrRequestFilter in
> > > Solr's web.xml
> >
> > I created a CustomFilter that would dump the request contents to a file,
> > I created the jar and added it to the solr.war in WEB_INF/lib folder
> > I edited the web.xml in the same folder to include the following lines:
> > <filter>
> >    <filter-name>CustomFilter</filter-name>
> >    <filter-class>(packagename).CustomFilter</filter-class>
> >  </filter>
> >
> > where CustomFilter is the name of the class extending
> > javax.servlet.Filter.
> >
> > I don't see anything in the contents of the file..
> >
> > thanks for your help
> > -umar
> >
> >
> > >
> > > Look at
> > >
> > >
> >
> http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
> > > more details.
> > >
> > > On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com> wrote:
> > >
> > > > On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
> > > > shalinmangar@gmail.com> wrote:
> > > >
> > > > > ServletRequest and ServletRequestWrapper are part of the Java
> > > > servlet-api
> > > > > (not Solr). Basically, Koji is hinting at writing a ServletFilter
> > > > > implementation (again using servlet-api) and creating a wrapper
> > > > > ServletRequest which modifies the underlying request params which
> > can
> > > > then
> > > > > be used by Solr.
> > > > >
> > > >
> > > > sorry for the silly question, basically i am new to servlets.
> > > > Now If my understanding is right , I will need to create a
> > > servlet/wrapper
> > > > that would listen the user facing queries and then pass the
> processed
> > > text
> > > > to solr request handler and I need to pack this servlet class file
> > into
> > > > Solr
> > > > war file.
> > > >
> > > > But How would I ensure that my servlet is called instead of solr
> > request
> > > > handler?
> > > >
> > > >
> > > > > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com>
> > wrote:
> > > > >
> > > > > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <
> > koji@r.email.ne.jp>
> > > > > > wrote:
> > > > > >
> > > > > > > Hi Umar,
> > > > > > >
> > > > > > > You may be able to preprocess your request parameter in your
> > > > > > > servlet filter. In the doFilter() method, you do:
> > > > > > >
> > > > > > > ServletRequest myRequest = new MyServletRequestWrapper(
> request
> > );
> > > > > >
> > > > > >
> > > > > > Thanks for your response,
> > > > > >
> > > > > > Where is the ServletRequest class , I am using Solr 1.3 trunk
> code
> > > > > > found SolrServletm, butit is depricated, which class can I use
> > > instead
> > > > > of
> > > > > > SolrRequest in 1.3 codebase?
> > > > > >
> > > > > >
> > > > > > I also tried overloading Standard request handler , How do I re
> > > write
> > > > > > queryparams there?
> > > > > >
> > > > > > Can you point me to some documentation?
> > > > > >
> > > > > >
> > > > > > >   :
> > > > > > > chain.doFilter( myRequest, response );
> > > > > > >
> > > > > > > And you have MyServletRequestWrapper that extends
> > > > > ServletRequestWrapper.
> > > > > > > Then you can get|set q* parameters through getParameter()
> > method.
> > > > > > >
> > > > > > > Hope this helps,
> > > > > > >
> > > > > > > Koji
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Umar Shah wrote:
> > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > Due some requirement I need to transform the user queries
> > before
> > > > > > passing
> > > > > > > > it
> > > > > > > > to the standard handler in Solr,  can anyone suggest me the
> > best
> > > > way
> > > > > > to
> > > > > > > > do
> > > > > > > > this.
> > > > > > > >
> > > > > > > > I will need to use a transfomation class that would provide
> > > > > functions
> > > > > > to
> > > > > > > > process the input query 'qIn' and transform it to the
> > resultant
> > > > > query
> > > > > > > > 'qOut'
> > > > > > > > and then pass it to solr handler as if qOut were the
> original
> > > user
> > > > > > > > query.
> > > > > > > >
> > > > > > > > thanks in anticipation,
> > > > > > > > -umar
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Shalin Shekhar Mangar.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Regards,
> > > Shalin Shekhar Mangar.
> > >
> >
>
>
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: help for preprocessing the query

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
Did you put a filter-mapping in web.xml?

On Tue, May 13, 2008 at 4:20 PM, Umar Shah <um...@wisdomtap.com> wrote:

> On Mon, May 12, 2008 at 10:30 PM, Shalin Shekhar Mangar <
> shalinmangar@gmail.com> wrote:
>
> > You'll *not* write a servlet. You'll write implement the Filter
> interface
> > http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html
> >
> > In the doFilter method, you'll create a ServletRequestWrapper which
> > changes
> > the incoming param. Then you'll call chain.doFilter with the new request
> > object. You'll need to add this filter before the SolrRequestFilter in
> > Solr's web.xml
>
> I created a CustomFilter that would dump the request contents to a file,
> I created the jar and added it to the solr.war in WEB_INF/lib folder
> I edited the web.xml in the same folder to include the following lines:
> <filter>
>    <filter-name>CustomFilter</filter-name>
>    <filter-class>(packagename).CustomFilter</filter-class>
>  </filter>
>
> where CustomFilter is the name of the class extending
> javax.servlet.Filter.
>
> I don't see anything in the contents of the file..
>
> thanks for your help
> -umar
>
>
> >
> > Look at
> >
> >
> http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
> > more details.
> >
> > On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com> wrote:
> >
> > > On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
> > > shalinmangar@gmail.com> wrote:
> > >
> > > > ServletRequest and ServletRequestWrapper are part of the Java
> > > servlet-api
> > > > (not Solr). Basically, Koji is hinting at writing a ServletFilter
> > > > implementation (again using servlet-api) and creating a wrapper
> > > > ServletRequest which modifies the underlying request params which
> can
> > > then
> > > > be used by Solr.
> > > >
> > >
> > > sorry for the silly question, basically i am new to servlets.
> > > Now If my understanding is right , I will need to create a
> > servlet/wrapper
> > > that would listen the user facing queries and then pass the processed
> > text
> > > to solr request handler and I need to pack this servlet class file
> into
> > > Solr
> > > war file.
> > >
> > > But How would I ensure that my servlet is called instead of solr
> request
> > > handler?
> > >
> > >
> > > > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com>
> wrote:
> > > >
> > > > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <
> koji@r.email.ne.jp>
> > > > > wrote:
> > > > >
> > > > > > Hi Umar,
> > > > > >
> > > > > > You may be able to preprocess your request parameter in your
> > > > > > servlet filter. In the doFilter() method, you do:
> > > > > >
> > > > > > ServletRequest myRequest = new MyServletRequestWrapper( request
> );
> > > > >
> > > > >
> > > > > Thanks for your response,
> > > > >
> > > > > Where is the ServletRequest class , I am using Solr 1.3 trunk code
> > > > > found SolrServletm, butit is depricated, which class can I use
> > instead
> > > > of
> > > > > SolrRequest in 1.3 codebase?
> > > > >
> > > > >
> > > > > I also tried overloading Standard request handler , How do I re
> > write
> > > > > queryparams there?
> > > > >
> > > > > Can you point me to some documentation?
> > > > >
> > > > >
> > > > > >   :
> > > > > > chain.doFilter( myRequest, response );
> > > > > >
> > > > > > And you have MyServletRequestWrapper that extends
> > > > ServletRequestWrapper.
> > > > > > Then you can get|set q* parameters through getParameter()
> method.
> > > > > >
> > > > > > Hope this helps,
> > > > > >
> > > > > > Koji
> > > > > >
> > > > > >
> > > > > >
> > > > > > Umar Shah wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > Due some requirement I need to transform the user queries
> before
> > > > > passing
> > > > > > > it
> > > > > > > to the standard handler in Solr,  can anyone suggest me the
> best
> > > way
> > > > > to
> > > > > > > do
> > > > > > > this.
> > > > > > >
> > > > > > > I will need to use a transfomation class that would provide
> > > > functions
> > > > > to
> > > > > > > process the input query 'qIn' and transform it to the
> resultant
> > > > query
> > > > > > > 'qOut'
> > > > > > > and then pass it to solr handler as if qOut were the original
> > user
> > > > > > > query.
> > > > > > >
> > > > > > > thanks in anticipation,
> > > > > > > -umar
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Shalin Shekhar Mangar.
> > > >
> > >
> >
> >
> >
> > --
> > Regards,
> > Shalin Shekhar Mangar.
> >
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: help for preprocessing the query

Posted by Umar Shah <um...@wisdomtap.com>.
On Mon, May 12, 2008 at 10:30 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> You'll *not* write a servlet. You'll write implement the Filter interface
> http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html
>
> In the doFilter method, you'll create a ServletRequestWrapper which
> changes
> the incoming param. Then you'll call chain.doFilter with the new request
> object. You'll need to add this filter before the SolrRequestFilter in
> Solr's web.xml

I created a CustomFilter that would dump the request contents to a file,
I created the jar and added it to the solr.war in WEB_INF/lib folder
I edited the web.xml in the same folder to include the following lines:
<filter>
    <filter-name>CustomFilter</filter-name>
    <filter-class>(packagename).CustomFilter</filter-class>
  </filter>

where CustomFilter is the name of the class extending javax.servlet.Filter.

I don't see anything in the contents of the file..

thanks for your help
-umar


>
> Look at
>
> http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
> more details.
>
> On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com> wrote:
>
> > On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
> > shalinmangar@gmail.com> wrote:
> >
> > > ServletRequest and ServletRequestWrapper are part of the Java
> > servlet-api
> > > (not Solr). Basically, Koji is hinting at writing a ServletFilter
> > > implementation (again using servlet-api) and creating a wrapper
> > > ServletRequest which modifies the underlying request params which can
> > then
> > > be used by Solr.
> > >
> >
> > sorry for the silly question, basically i am new to servlets.
> > Now If my understanding is right , I will need to create a
> servlet/wrapper
> > that would listen the user facing queries and then pass the processed
> text
> > to solr request handler and I need to pack this servlet class file into
> > Solr
> > war file.
> >
> > But How would I ensure that my servlet is called instead of solr request
> > handler?
> >
> >
> > > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com> wrote:
> > >
> > > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <ko...@r.email.ne.jp>
> > > > wrote:
> > > >
> > > > > Hi Umar,
> > > > >
> > > > > You may be able to preprocess your request parameter in your
> > > > > servlet filter. In the doFilter() method, you do:
> > > > >
> > > > > ServletRequest myRequest = new MyServletRequestWrapper( request );
> > > >
> > > >
> > > > Thanks for your response,
> > > >
> > > > Where is the ServletRequest class , I am using Solr 1.3 trunk code
> > > > found SolrServletm, butit is depricated, which class can I use
> instead
> > > of
> > > > SolrRequest in 1.3 codebase?
> > > >
> > > >
> > > > I also tried overloading Standard request handler , How do I re
> write
> > > > queryparams there?
> > > >
> > > > Can you point me to some documentation?
> > > >
> > > >
> > > > >   :
> > > > > chain.doFilter( myRequest, response );
> > > > >
> > > > > And you have MyServletRequestWrapper that extends
> > > ServletRequestWrapper.
> > > > > Then you can get|set q* parameters through getParameter() method.
> > > > >
> > > > > Hope this helps,
> > > > >
> > > > > Koji
> > > > >
> > > > >
> > > > >
> > > > > Umar Shah wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > Due some requirement I need to transform the user queries before
> > > > passing
> > > > > > it
> > > > > > to the standard handler in Solr,  can anyone suggest me the best
> > way
> > > > to
> > > > > > do
> > > > > > this.
> > > > > >
> > > > > > I will need to use a transfomation class that would provide
> > > functions
> > > > to
> > > > > > process the input query 'qIn' and transform it to the resultant
> > > query
> > > > > > 'qOut'
> > > > > > and then pass it to solr handler as if qOut were the original
> user
> > > > > > query.
> > > > > >
> > > > > > thanks in anticipation,
> > > > > > -umar
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Regards,
> > > Shalin Shekhar Mangar.
> > >
> >
>
>
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: help for preprocessing the query

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
You'll *not* write a servlet. You'll write implement the Filter interface
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Filter.html

In the doFilter method, you'll create a ServletRequestWrapper which changes
the incoming param. Then you'll call chain.doFilter with the new request
object. You'll need to add this filter before the SolrRequestFilter in
Solr's web.xml

Look at
http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=1for
more details.

On Mon, May 12, 2008 at 8:51 PM, Umar Shah <um...@wisdomtap.com> wrote:

> On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
> shalinmangar@gmail.com> wrote:
>
> > ServletRequest and ServletRequestWrapper are part of the Java
> servlet-api
> > (not Solr). Basically, Koji is hinting at writing a ServletFilter
> > implementation (again using servlet-api) and creating a wrapper
> > ServletRequest which modifies the underlying request params which can
> then
> > be used by Solr.
> >
>
> sorry for the silly question, basically i am new to servlets.
> Now If my understanding is right , I will need to create a servlet/wrapper
> that would listen the user facing queries and then pass the processed text
> to solr request handler and I need to pack this servlet class file into
> Solr
> war file.
>
> But How would I ensure that my servlet is called instead of solr request
> handler?
>
>
> > On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com> wrote:
> >
> > > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <ko...@r.email.ne.jp>
> > > wrote:
> > >
> > > > Hi Umar,
> > > >
> > > > You may be able to preprocess your request parameter in your
> > > > servlet filter. In the doFilter() method, you do:
> > > >
> > > > ServletRequest myRequest = new MyServletRequestWrapper( request );
> > >
> > >
> > > Thanks for your response,
> > >
> > > Where is the ServletRequest class , I am using Solr 1.3 trunk code
> > > found SolrServletm, butit is depricated, which class can I use instead
> > of
> > > SolrRequest in 1.3 codebase?
> > >
> > >
> > > I also tried overloading Standard request handler , How do I re write
> > > queryparams there?
> > >
> > > Can you point me to some documentation?
> > >
> > >
> > > >   :
> > > > chain.doFilter( myRequest, response );
> > > >
> > > > And you have MyServletRequestWrapper that extends
> > ServletRequestWrapper.
> > > > Then you can get|set q* parameters through getParameter() method.
> > > >
> > > > Hope this helps,
> > > >
> > > > Koji
> > > >
> > > >
> > > >
> > > > Umar Shah wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Due some requirement I need to transform the user queries before
> > > passing
> > > > > it
> > > > > to the standard handler in Solr,  can anyone suggest me the best
> way
> > > to
> > > > > do
> > > > > this.
> > > > >
> > > > > I will need to use a transfomation class that would provide
> > functions
> > > to
> > > > > process the input query 'qIn' and transform it to the resultant
> > query
> > > > > 'qOut'
> > > > > and then pass it to solr handler as if qOut were the original user
> > > > > query.
> > > > >
> > > > > thanks in anticipation,
> > > > > -umar
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > Regards,
> > Shalin Shekhar Mangar.
> >
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: help for preprocessing the query

Posted by Umar Shah <um...@wisdomtap.com>.
On Mon, May 12, 2008 at 8:42 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> ServletRequest and ServletRequestWrapper are part of the Java servlet-api
> (not Solr). Basically, Koji is hinting at writing a ServletFilter
> implementation (again using servlet-api) and creating a wrapper
> ServletRequest which modifies the underlying request params which can then
> be used by Solr.
>

sorry for the silly question, basically i am new to servlets.
Now If my understanding is right , I will need to create a servlet/wrapper
that would listen the user facing queries and then pass the processed text
to solr request handler and I need to pack this servlet class file into Solr
war file.

But How would I ensure that my servlet is called instead of solr request
handler?


> On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com> wrote:
>
> > On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <ko...@r.email.ne.jp>
> > wrote:
> >
> > > Hi Umar,
> > >
> > > You may be able to preprocess your request parameter in your
> > > servlet filter. In the doFilter() method, you do:
> > >
> > > ServletRequest myRequest = new MyServletRequestWrapper( request );
> >
> >
> > Thanks for your response,
> >
> > Where is the ServletRequest class , I am using Solr 1.3 trunk code
> > found SolrServletm, butit is depricated, which class can I use instead
> of
> > SolrRequest in 1.3 codebase?
> >
> >
> > I also tried overloading Standard request handler , How do I re write
> > queryparams there?
> >
> > Can you point me to some documentation?
> >
> >
> > >   :
> > > chain.doFilter( myRequest, response );
> > >
> > > And you have MyServletRequestWrapper that extends
> ServletRequestWrapper.
> > > Then you can get|set q* parameters through getParameter() method.
> > >
> > > Hope this helps,
> > >
> > > Koji
> > >
> > >
> > >
> > > Umar Shah wrote:
> > >
> > > > Hi,
> > > >
> > > > Due some requirement I need to transform the user queries before
> > passing
> > > > it
> > > > to the standard handler in Solr,  can anyone suggest me the best way
> > to
> > > > do
> > > > this.
> > > >
> > > > I will need to use a transfomation class that would provide
> functions
> > to
> > > > process the input query 'qIn' and transform it to the resultant
> query
> > > > 'qOut'
> > > > and then pass it to solr handler as if qOut were the original user
> > > > query.
> > > >
> > > > thanks in anticipation,
> > > > -umar
> > > >
> > > >
> > > >
> > >
> > >
> >
>
>
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: help for preprocessing the query

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
ServletRequest and ServletRequestWrapper are part of the Java servlet-api
(not Solr). Basically, Koji is hinting at writing a ServletFilter
implementation (again using servlet-api) and creating a wrapper
ServletRequest which modifies the underlying request params which can then
be used by Solr.

On Mon, May 12, 2008 at 8:36 PM, Umar Shah <um...@wisdomtap.com> wrote:

> On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <ko...@r.email.ne.jp>
> wrote:
>
> > Hi Umar,
> >
> > You may be able to preprocess your request parameter in your
> > servlet filter. In the doFilter() method, you do:
> >
> > ServletRequest myRequest = new MyServletRequestWrapper( request );
>
>
> Thanks for your response,
>
> Where is the ServletRequest class , I am using Solr 1.3 trunk code
> found SolrServletm, butit is depricated, which class can I use instead of
> SolrRequest in 1.3 codebase?
>
>
> I also tried overloading Standard request handler , How do I re write
> queryparams there?
>
> Can you point me to some documentation?
>
>
> >   :
> > chain.doFilter( myRequest, response );
> >
> > And you have MyServletRequestWrapper that extends ServletRequestWrapper.
> > Then you can get|set q* parameters through getParameter() method.
> >
> > Hope this helps,
> >
> > Koji
> >
> >
> >
> > Umar Shah wrote:
> >
> > > Hi,
> > >
> > > Due some requirement I need to transform the user queries before
> passing
> > > it
> > > to the standard handler in Solr,  can anyone suggest me the best way
> to
> > > do
> > > this.
> > >
> > > I will need to use a transfomation class that would provide functions
> to
> > > process the input query 'qIn' and transform it to the resultant query
> > > 'qOut'
> > > and then pass it to solr handler as if qOut were the original user
> > > query.
> > >
> > > thanks in anticipation,
> > > -umar
> > >
> > >
> > >
> >
> >
>



-- 
Regards,
Shalin Shekhar Mangar.

Re: help for preprocessing the query

Posted by Umar Shah <um...@wisdomtap.com>.
On Mon, May 12, 2008 at 2:50 PM, Koji Sekiguchi <ko...@r.email.ne.jp> wrote:

> Hi Umar,
>
> You may be able to preprocess your request parameter in your
> servlet filter. In the doFilter() method, you do:
>
> ServletRequest myRequest = new MyServletRequestWrapper( request );


Thanks for your response,

Where is the ServletRequest class , I am using Solr 1.3 trunk code
found SolrServletm, butit is depricated, which class can I use instead of
SolrRequest in 1.3 codebase?


I also tried overloading Standard request handler , How do I re write
queryparams there?

Can you point me to some documentation?


>   :
> chain.doFilter( myRequest, response );
>
> And you have MyServletRequestWrapper that extends ServletRequestWrapper.
> Then you can get|set q* parameters through getParameter() method.
>
> Hope this helps,
>
> Koji
>
>
>
> Umar Shah wrote:
>
> > Hi,
> >
> > Due some requirement I need to transform the user queries before passing
> > it
> > to the standard handler in Solr,  can anyone suggest me the best way to
> > do
> > this.
> >
> > I will need to use a transfomation class that would provide functions to
> > process the input query 'qIn' and transform it to the resultant query
> > 'qOut'
> > and then pass it to solr handler as if qOut were the original user
> > query.
> >
> > thanks in anticipation,
> > -umar
> >
> >
> >
>
>

Re: help for preprocessing the query

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
Hi Umar,

You may be able to preprocess your request parameter in your
servlet filter. In the doFilter() method, you do:

ServletRequest myRequest = new MyServletRequestWrapper( request );
    :
chain.doFilter( myRequest, response );

And you have MyServletRequestWrapper that extends ServletRequestWrapper.
Then you can get|set q* parameters through getParameter() method.

Hope this helps,

Koji


Umar Shah wrote:
> Hi,
>
> Due some requirement I need to transform the user queries before passing it
> to the standard handler in Solr,  can anyone suggest me the best way to do
> this.
>
> I will need to use a transfomation class that would provide functions to
> process the input query 'qIn' and transform it to the resultant query 'qOut'
> and then pass it to solr handler as if qOut were the original user query.
>
> thanks in anticipation,
> -umar
>
>   


Re: help for preprocessing the query

Posted by Grant Ingersoll <gs...@apache.org>.
I haven't written one, but I _think_ you could just implement a  
QParser that does the transformation.  See the LuceneQParser or the  
DismaxQParser.



On May 12, 2008, at 4:59 AM, Umar Shah wrote:

> Hi,
>
> Due some requirement I need to transform the user queries before  
> passing it
> to the standard handler in Solr,  can anyone suggest me the best way  
> to do
> this.
>
> I will need to use a transfomation class that would provide  
> functions to
> process the input query 'qIn' and transform it to the resultant  
> query 'qOut'
> and then pass it to solr handler as if qOut were the original user  
> query.
>
> thanks in anticipation,
> -umar