I am trying to suppress the error messages received when a value is not
passed to a query, 

Ex:

/select?first_name=peter&fq=$first_name&q=*:*

I don't want the above query to throw error or die whenever the variable
first_name is not passed to the query hence I came up with a plugin to
return null whenever the variable is not passed in the query. The below code
works fine for 'q' but doesn't work for 'fq' parameter.

Something like...

public class OptionalQParserPlugin extends QParserPlugin {
        public QParser createParser(String qstr, SolrParams localParams,
                        SolrParams params, SolrQueryRequest req) {
                if (qstr == null || qstr.trim().length() < 1) {
                        return new QParser(qstr, localParams, params, req) {
                                @Override
                                public Query parse() throws SyntaxError {
                                        return null;
                                }
                        };
                }
}

 Can someone let me know how to make fq variables optional?



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-create-optional-fq-plugin-tp4077000.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to