Class: Sunspot::Query::QueryFacet

Inherits:
Connective::Conjunction show all
Defined in:
lib/sunspot/query/query_facet.rb

Instance Method Summary collapse

Methods inherited from Connective::Conjunction

#add_conjunction, inverse

Methods inherited from Connective::Abstract

#add_component, #add_conjunction, #add_disjunction, #add_negated_restriction, #add_negated_shorthand_restriction, #add_positive_restriction, #add_positive_shorthand_restriction, #add_restriction, #add_shorthand_restriction, #negate, #negated?

Methods included from Filter

#tag, #to_filter_query

Constructor Details

#initialize(options = {}, negated = false) ⇒ QueryFacet

Returns a new instance of QueryFacet.



5
6
7
8
9
10
11
12
# File 'lib/sunspot/query/query_facet.rb', line 5

def initialize(options = {}, negated = false)
  if exclude_filters = options[:exclude]
    @exclude_tag = Util.Array(exclude_filters).map do |filter|
      filter.tag
    end.join(',')
  end
  super(negated)
end

Instance Method Details

#to_boolean_phraseObject



26
27
28
# File 'lib/sunspot/query/query_facet.rb', line 26

def to_boolean_phrase
  "#{to_local_params}#{super}"
end

#to_paramsObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/sunspot/query/query_facet.rb', line 15

def to_params
  if @components.empty?
    {}
  else
    {
      :facet => 'true',
      :"facet.query" => to_boolean_phrase
    }
  end
end