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 Riyaz <sh...@viacomcontractor.com> on 2018/05/29 11:10:09 UTC

sending empty request parameters to solr

Hi,
We had come across a requirement to allow empty parameter values to query
string(q), start and rows as part of solr search query. 

In solr 3.4, have added defType to edismax and it's allowing empty params

http://<solrhost>/solr/<core>/select?&wt=xml&indent=true&rows=&start=" 
-->working fine in solr 3.4

Configs:

<requestHandler name="standard" class="solr.StandardRequestHandler"
default="true">
	<lst name="defaults">
		<str name="echoParams">explicit</str>
		<int name="rows">10</int>
		*<str name="q.alt">*:*</str>
		<str name="defType">edismax</str>*
	</lst>
	<arr name="last-components">
	</arr>
</requestHandler>

while applying the same changes in solr-5.3.1, empty rows/start parameter
causing "java.lang.NumberFormatException: For input string: """.

Can you please let us know, is there any way to do this?.
Thanks
Riyaz



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: sending empty request parameters to solr

Posted by Shawn Heisey <ap...@elyograg.org>.
On 5/29/2018 5:10 AM, Riyaz wrote:
> We had come across a requirement to allow empty parameter values to query
> string(q), start and rows as part of solr search query.
>
> In solr 3.4, have added defType to edismax and it's allowing empty params
>
> http://<solrhost>/solr/<core>/select?&wt=xml&indent=true&rows=&start="
> -->working fine in solr 3.4

I would say that the behavior in 3.x is the problem here. Version 3.4.0 
is nearly seven years old.

An empty value for the "q" parameter is a situation that Solr is 
explicitly looking for.  When q is missing or empty, the value in q.alt 
is used instead, with the standard Lucene parser.

Behavior is undefined for an empty value on parameters like start and rows.

> while applying the same changes in solr-5.3.1, empty rows/start parameter
> causing "java.lang.NumberFormatException: For input string: """.

The newer version is validating that what you're sending is an actual 
valid number, and throwing an error early when it's not.  The latest 
version I have downloaded right now is 7.3.0, and it behaves the same as 
5.3.1.  The latest 3.x (3.6.2) accepts the empty parameters, and the 
latest 4.x (4.10.4) does not accept them.  As you have seen, 5.x doesn't 
accept them.  All three of these major versions are out of date and no 
longer receive updates.  I did not try any 6.x versions for this 
problem, but they probably behave the same as 5.x and 7.x.

> Can you please let us know, is there any way to do this?.

If you want a query to use defaults for these parameters, don't include 
them on the query URL at all.  Solr will use the defaults that you have 
defined on the handler in solrconfig.xml.

I don't consider the behavior you're seeing to be a bug.  I think that 
it's correct to throw an error in this situation, and that 3.x behaves 
incorrectly by NOT throwing an error.

Thanks,
Shawn