Commit 5d7759f7 authored by Tollef Fog Heen's avatar Tollef Fog Heen Committed by Bryan McLellan
Browse files

Validate q param to search, handle foo:* specially

Give a Bad request error if this doesn't look like a valid query
string, and if people try to search for key:*, rewrite it to [* TO *]
to work around solr limitation.
parent 8438c348
......@@ -45,6 +45,14 @@ class Search < Application
params[:sort] ||= nil
params[:start] ||= 0
params[:rows] ||= 20
(k,v) = params[:q].split(":")
if k.nil? or v.nil?
raise BadRequest, "invalid q parameter"
elsif v == "*" and k != "*"
params[:q] = "#{k}:[* TO *]"
objects, start, total =[:id], params[:q], params[:sort], params[:start], params[:rows])
"rows" => objects,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment