Module: Sunspot::Query::Filter
- Included in:
- Connective::Abstract, Restriction::Base
- Defined in:
- sunspot/lib/sunspot/query/filter.rb
Instance Method Summary (collapse)
-
- (Object) tag
Generate and return a tag that can be attached to this restriction, for use with multiselect faceting.
-
- (Object) to_filter_query
Express this filter as an :fq parameter; i.e., the boolean phrase, maybe prefixed by local params.
Instance Method Details
- (Object) tag
Generate and return a tag that can be attached to this restriction, for use with multiselect faceting. This needs to be unique, but doesn’t really need to be human-readable, so just generate a string based on the hash of the boolean phrase.
21 22 23 |
# File 'sunspot/lib/sunspot/query/filter.rb', line 21 def tag @tag ||= to_boolean_phrase.hash.abs.to_s(36) end |
- (Object) to_filter_query
Express this filter as an :fq parameter; i.e., the boolean phrase, maybe prefixed by local params.
9 10 11 12 13 |
# File 'sunspot/lib/sunspot/query/filter.rb', line 9 def to_filter_query if tagged? then "{!tag=#{tag}}#{to_boolean_phrase}" else to_boolean_phrase end end |