Let’s say I have a model defined as follows (title and description are string and text fields, respectively):
class Entity < ActiveRecord::Base
# Skipped
searchable do
text :title,
text :description
end
end
I want to be able to use search queries like “title:foo description:bar”, which assumed to retrieve only those Entities which fields meet the search criteria, i.e. Entities which title contains “foo” and/or description contains “bar”. Exact syntax doesn’t matter.
I tried to type such query in the search field of my demo application, but obviously it didn’t return any results 🙂
So, does Sunspot query parser support fielded queries (don’t sure if the term is correct)?
Thanks.
That’s a feature that Solr’s edismax query parser should support. However Sunspot currently defaults to the older dismax query parser.
To enable edismax in your searches, try this line in your
searchblock:(That’s off the top of my head; let me know if I missed the syntax.)