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 Bernd Fehling <be...@uni-bielefeld.de> on 2012/11/30 16:05:08 UTC

DefaultSolrParams ?

Dear list,

after going from 3.6 to 4.0 I see exceptions in my logs.
It turned out that somehow the "q"-parameter was empty.
With 3.6 the "q.alt" in the solrconfig.xml worked as fallback but now with 4.0 I get exceptions.

I use it like this:
SolrParams params = req.getParams();
String q = params.get(CommonParams.Q).trim();

The exception is from the second line if "q" is empty.
I can see "q.alt=*:*" in my defaults within params.

So why is it not picking up "q.alt" if "q" is empty?

Regards
Bernd

Re: DefaultSolrParams ?

Posted by Erik Hatcher <er...@gmail.com>.
Bernd -

There never has been, nor is there now, a method that looks for q and falls back to q.alt.  The logic for that is purely in DisMaxQParser.java:

    if (userQuery == null || userQuery.trim().length() < 1) {
      // If no query is specified, we may have an alternate
      altUserQuery = getAlternateUserQuery(solrParams);
      if (altUserQuery == null)
        return false;
      query.add(altUserQuery, BooleanClause.Occur.MUST);
    }

I'm not sure what you're experiencing different from 3.6 to 4.0.  

Tell us the details of your custom plugin if you'd like help in digging deeper into what's going on.

	Erik


On Dec 2, 2012, at 08:15 , Bernd Fehling wrote:

> Hi Hoss,
> my config has definately not changed and it worked with 3.6 and 3.6.1.
> Yes I have a custom plugin and if q was empty with 3.6 it picked automatically q.alt from solrconfig.xml.
> This all was done with params.get()
> With 4.x this is gone due to some changes in DefaultSolrParams(?).
> Which is now the method to get q from params and have an automatic fallback to q.alt?
> 
> Bernd
> 
>> 
>> : I use it like this:
>> : SolrParams params = req.getParams();
>> : String q = params.get(CommonParams.Q).trim();
>> : 
>> : The exception is from the second line if "q" is empty.
>> : I can see "q.alt=*:*" in my defaults within params.
>> : 
>> : So why is it not picking up "q.alt" if "q" is empty?
>> 
>> Youre talking about some sort of custom solr plugin that you 
>> have correct?
>> 
>> when you are accessing a SolrParams object, there is nothing 
>> magic about 
>> "q" and "q.alt" -- params.get() will only return the value 
>> specified for 
>> the param name you ask about.  The logic for using "q.alt" 
>> (aka: 
>> "DisMaxParams.ALTQ") if "q" doesn't exist in the params (or is 
>> blank) has 
>> always been a specific feature of the DisMaxQParser.
>> 
>> So if you are suddenly getting an NPE when q is missing, perhaps 
>> the 
>> problem is that in your old configs there was a default "q" 
>> containing hte 
>> empty string, and now that's gone?
>> 
>> 
>> -Hoss


Re: DefaultSolrParams ?

Posted by Bernd Fehling <be...@uni-bielefeld.de>.
Hi Hoss,
my config has definately not changed and it worked with 3.6 and 3.6.1.
Yes I have a custom plugin and if q was empty with 3.6 it picked automatically q.alt from solrconfig.xml.
This all was done with params.get()
With 4.x this is gone due to some changes in DefaultSolrParams(?).
Which is now the method to get q from params and have an automatic fallback to q.alt?

Bernd

> 
> : I use it like this:
> : SolrParams params = req.getParams();
> : String q = params.get(CommonParams.Q).trim();
> : 
> : The exception is from the second line if "q" is empty.
> : I can see "q.alt=*:*" in my defaults within params.
> : 
> : So why is it not picking up "q.alt" if "q" is empty?
> 
> Youre talking about some sort of custom solr plugin that you 
> have correct?
> 
> when you are accessing a SolrParams object, there is nothing 
> magic about 
> "q" and "q.alt" -- params.get() will only return the value 
> specified for 
> the param name you ask about.  The logic for using "q.alt" 
> (aka: 
> "DisMaxParams.ALTQ") if "q" doesn't exist in the params (or is 
> blank) has 
> always been a specific feature of the DisMaxQParser.
> 
> So if you are suddenly getting an NPE when q is missing, perhaps 
> the 
> problem is that in your old configs there was a default "q" 
> containing hte 
> empty string, and now that's gone?
> 
> 
> -Hoss

Re: DefaultSolrParams ?

Posted by Chris Hostetter <ho...@fucit.org>.
: I use it like this:
: SolrParams params = req.getParams();
: String q = params.get(CommonParams.Q).trim();
: 
: The exception is from the second line if "q" is empty.
: I can see "q.alt=*:*" in my defaults within params.
: 
: So why is it not picking up "q.alt" if "q" is empty?

Youre talking about some sort of custom solr plugin that you have correct?

when you are accessing a SolrParams object, there is nothing magic about 
"q" and "q.alt" -- params.get() will only return the value specified for 
the param name you ask about.  The logic for using "q.alt" (aka: 
"DisMaxParams.ALTQ") if "q" doesn't exist in the params (or is blank) has 
always been a specific feature of the DisMaxQParser.

So if you are suddenly getting an NPE when q is missing, perhaps the 
problem is that in your old configs there was a default "q" containing hte 
empty string, and now that's gone?


-Hoss