I am converting a Rails application from using acts_as_solr to a sunspot.
The application takes advantage of the field search feature in solr, which was introduced in acts_as_solr. You could give it a query string, for example:
title:"The thing to search"
and will look for this line in the header field.
When converting to a sunspot, I analyze the field-specific parts of the query string, and I need to dynamically generate a search block. Like that:
Sunspot.search (table_clazz) do
keywords (first_string,: fields =>: title)
keywords (second_string,: fields =>: description)
...
paginate (: page => page,: per_page => per_page)
end
This is complicated by the fact that you also need to do duration intervals (seconds, integers) and negation if requested by the request.
In the current system, users can search for something in the header, excluding entries with something else in another field and viewing by duration.
In a nutshell, how can I generate these blocks dynamically?
source
share