lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Wesemann <>
Subject inconsistency in SolrParams.get()
Date Tue, 04 May 2010 20:56:42 GMT
Dear list,
I recently stumpled upon this:

modifiableParams = new ModifiableSolrParams( req.getParams() );

assert modifiableParams.get("key").equals( req.getParams().get("key") );

this test fails for requests built from a SimpleRequestParser or 
StandardRequestParser where the parameter "key" was given, but empty ( 
e.g. localhost:8393/select/?key=&para1=val1&parm2=val2 ).

The reason is that oas.request.ServletSolrParams returns null for values 
with length() == 0,
but all other SolrParams implementations return the empty String.

This behaviour has also side effects on search components:
Most, if not all, standard search components check for something like

if (reg.getParams().getBool(myTriggerParameter, false) ) { what I am supposed to do...


In case of ServletSolrParams getBool() returns the desired and expected 
all other Implementations throw a "bad request" Exception.
One may argue that suppling a parameter with an empty value indeed is a 
malformed request,
but as an example, in our frontend servers we use a Perllib which always 
adds the "q" parameter to a SolrRequest
( and our Solr implementation allows  requests without a explicit query ).

Nonetheless I think, the above mentioned equality check should hold true 
for any request and any SolrParams.
Because I cannot oversee the implications, I currently don't have a 
better suggestion to achieve this, than
to make ServleSolrParams also return the empty String, which is in my 
opinion counter-intuitive and does not the right thing for the 
getBool(), getInt() etc. cases.
Any thoughts?

is ModifiableSolrParams.set(key, null) removes key from the params 
really the desired and expected behaviour?


mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web:
Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky

View raw message