So I’ve implemented the sunspot_rails gem into my application to utilize the powerful Solr search engine. I recently checked out Ryan’s railscast on full-text searching and I noticed he was using additional parameters in his search queries such as “-“ to denote something that should NOT be including in the full-text search.
I never heard about this until now, I was wondering if there was a user-friendly usage guide somewhere both me and my users can reference to take my search functionality to it’s maximum capability.
I think ideally I would like to make an abridged version similar to Github’s markdown cheat-sheet for my search forms that users can quickly reference.
Sunspot uses Solr’s DisMax Query Parser, which has a very simple query syntax. For the most part, it is intended to flexibly parse user-created queries.
DisMax recognizes three special characters:
+,-, and". From the documentation:There are a few other “behind the scenes” options to tune the relevancy of matched documents. For example, “minimum match” specifies the number or proportion of “optional” fields (i.e., not prefixed with
-or+) which must be present. As well as options to boost term matches in specific fields, or term matches within close proximity to each other, and so on.In Sunspot, these are all exposed in the
optionsparameter to thefulltextmethod, or as methods within a block supplied to that method.