: David, I felt like there should be a flag with which we can either throw the
: error message or do nothing in case of bad inputs.. 

As erik alluded to in his response, you should be able to configure an 
"appended" fq using the "switch" QParserPlugin to get something like what you 
are 
describing, by taking advantage of the "default" behavior.

I think you'd want something along the lines of...

<lst name="defaults">
  <int name="fps_dist">50</int> <!-- or whatever default you want -->
</lst>
<lst name="appends">
  <str name="fq">{!switch case='*:*' default=$fq_bbox v=$fps_latlong}</str>
</lst>
<lst name="invariants">
  <str name="fq_bbox">{!bbox pt=$fps_latlong sfield=geo d=$fps_dist}</str>
</lst>

The result of something like that should be:

 * if a user specifies a non blank fps_latlong param, the the query will 
be filtered using a bbox based on that center and the specified  fps_dist 
is (or the default fps_dist if the user didn't specify one)
 * if the user does not specify an fps_latlong param, or the fpls_latlong 
param is blank, then no effective filtering is done (the filter matches 
all docs)

Here's an equivilent example using the Solr 4.2.1 examle data and 
configs...

fps_latlong specified, matches a single document in the radius..

http://localhost:8983/solr/select?q=*:*&fps_dist=100&fps_bbox={!bbox%20pt=$fps_latlong%20sfield=store%20d=$fps_dist}&fq={!switch%20case=%27*:*%27%20default=$fps_bbox%20v=$fps_latlong}&fps_latlong=35.0752,-97.032


fps_latlong not specified, or blank, matches all docs...

http://localhost:8983/solr/select?q=*:*&fps_dist=100&fps_bbox={!bbox%20pt=$fps_latlong%20sfield=store%20d=$fps_dist}&fq={!switch%20case=%27*:*%27%20default=$fps_bbox%20v=$fps_latlong}&fps_latlong=
http://localhost:8983/solr/select?q=*:*&fps_dist=100&fps_bbox={!bbox%20pt=$fps_latlong%20sfield=store%20d=$fps_dist}&fq={!switch%20case=%27*:*%27%20default=$fps_bbox%20v=$fps_latlong}&fps_latlong=+++
http://localhost:8983/solr/select?q=*:*&fps_dist=100&fps_bbox={!bbox%20pt=$fps_latlong%20sfield=store%20d=$fps_dist}&fq={!switch%20case=%27*:*%27%20default=$fps_bbox%20v=$fps_latlong}


More info...

https://lucene.apache.org/solr/4_3_0/solr-core/org/apache/solr/search/SwitchQParserPlugin.html
http://searchhub.org/2013/02/20/custom-solr-request-params/


-Hoss

Reply via email to