Class: Elasticsearch::FacetedSearch::FacetGroup
- Inherits:
-
Object
- Object
- Elasticsearch::FacetedSearch::FacetGroup
- Extended by:
- Forwardable
- Defined in:
- lib/elasticsearch/faceted_search/facet_group.rb
Constant Summary collapse
- OPERATOR_MAPPING =
{ :and => ',', :or => '|' }
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#search ⇒ Object
Returns the value of attribute search.
Instance Method Summary collapse
- #group_params ⇒ Object
- #group_params_string ⇒ Object
-
#initialize(search, key, objects) ⇒ FacetGroup
constructor
delegate :class_facets, :execution_type, :search_params, to: :search.
- #items ⇒ Object
-
#operator ⇒ Object
Returns the string value ‘,’ or ‘|’.
- #operator_mappings(i = nil) ⇒ Object
- #selected_values ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(search, key, objects) ⇒ FacetGroup
delegate :class_facets, :execution_type, :search_params, to: :search
18 19 20 21 22 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 18 def initialize(search, key, objects) self.search = search self.key = key.to_sym self.objects = hit_count_mapping(objects['terms']) end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
13 14 15 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 13 def key @key end |
#objects ⇒ Object
Returns the value of attribute objects.
13 14 15 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 13 def objects @objects end |
#search ⇒ Object
Returns the value of attribute search.
13 14 15 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 13 def search @search end |
Instance Method Details
#group_params ⇒ Object
39 40 41 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 39 def group_params group_params_string.split(operator).dup end |
#group_params_string ⇒ Object
43 44 45 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 43 def group_params_string search_params.fetch(key, '') end |
#items ⇒ Object
24 25 26 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 24 def items @items ||= build_items end |
#operator ⇒ Object
Returns the string value ‘,’ or ‘|’
55 56 57 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 55 def operator @operator ||= operator_mappings(operator_for) end |
#operator_mappings(i = nil) ⇒ Object
59 60 61 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 59 def operator_mappings(i=nil) OPERATOR_MAPPING.fetch(i, nil) end |
#selected_values ⇒ Object
34 35 36 37 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 34 def selected_values v = search_params.fetch(key, '') operator ? v.split(operator).map(&:downcase) : v.downcase end |
#title ⇒ Object
28 29 30 31 32 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 28 def title class_facets[key][:title] rescue key.to_s.humanize end |
#type ⇒ Object
47 48 49 50 51 |
# File 'lib/elasticsearch/faceted_search/facet_group.rb', line 47 def type class_facets[key][:type] rescue nil end |