module Sunspot::Query::Filter

Public Instance Methods

tag() click to toggle source

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.

# File lib/sunspot/query/filter.rb, line 21
def tag
  @tag ||= to_boolean_phrase.hash.abs.to_s(36)
end
to_filter_query() click to toggle source

Express this filter as an :fq parameter; i.e., the boolean phrase, maybe prefixed by local params.

# File 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