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 sagarprasad <sa...@gmail.com> on 2014/10/01 09:27:13 UTC
Adding filter in custom query parser
I am new bee in SOLR and OpenNLP. I am trying to do a POC and want to write a
custom parser which can parse the query string using NLP and create an
appropriate SOLR query with filters.
For eg : "red shirt under 20$" should be translated to q=shirt&fq=price:[*
TO 20] and possibly apply color to one the attribute of doc index.
in parser overrided method, how can i add the filter and pass the query
back?
Any help pointers / sample code will be helpful.
-Thanks
--
View this message in context: http://lucene.472066.n3.nabble.com/Adding-filter-in-custom-query-parser-tp4162044.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Adding filter in custom query parser
Posted by Jack Krupansky <ja...@basetechnology.com>.
Unless you consider yourself to be a "Solr expert", it would be best to
implement such query translation in an application layer.
-- Jack Krupansky
-----Original Message-----
From: sagarprasad
Sent: Wednesday, October 1, 2014 3:27 AM
To: solr-user@lucene.apache.org
Subject: Adding filter in custom query parser
I am new bee in SOLR and OpenNLP. I am trying to do a POC and want to write
a
custom parser which can parse the query string using NLP and create an
appropriate SOLR query with filters.
For eg : "red shirt under 20$" should be translated to q=shirt&fq=price:[*
TO 20] and possibly apply color to one the attribute of doc index.
in parser overrided method, how can i add the filter and pass the query
back?
Any help pointers / sample code will be helpful.
-Thanks
--
View this message in context:
http://lucene.472066.n3.nabble.com/Adding-filter-in-custom-query-parser-tp4162044.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Adding filter in custom query parser
Posted by sagarprasad <sa...@gmail.com>.
Thanks Cris and Jack for you reply.
@Cris,
Can i some samples or examples of overriding search Component.
Performance wise, whether it is advisable to do this logic at application
layer or SOLR search component layer.
-Thanks
--
View this message in context: http://lucene.472066.n3.nabble.com/Adding-filter-in-custom-query-parser-tp4162044p4162757.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Adding filter in custom query parser
Posted by Chris Hostetter <ho...@fucit.org>.
: For eg : "red shirt under 20$" should be translated to q=shirt&fq=price:[*
: TO 20] and possibly apply color to one the attribute of doc index.
:
: in parser overrided method, how can i add the filter and pass the query
: back?
I don't think you can acomplish this just within the QParser API ... it's
really designed to produce a single Query, and might be used from multiple
contexts (ie: how would your custom parser behave if i tried to use it in
a facet.query?
Your best approach would probably be to implement a SearchComponent.
Either subclass QueryComponent and overriding where the q param is
passed to the default QParser, or by writting a standalone component that
comes first in the chain and ripping apart the q param before
QueryComponent ever sees it.
you can add your programatic filters via ResponseBuilder.setFilters() and
use ResponseBuilder.setQueryString() to leave whatever remaining user
input you want for QueryComponent to parse using the appropriate QParser.
the standalone SerachComponent route is probably the most straight
forward and easiest to maintain.
-Hoss
http://www.lucidworks.com/