Module: Blacklight::Solr::Response::Facets

Included in:
Blacklight::Solr::Response
Defined in:
lib/blacklight/solr/response/facets.rb

Defined Under Namespace

Classes: FacetField, FacetItem

Instance Method Summary collapse

Instance Method Details

#aggregationsObject

Get all the Solr facet data (fields, queries, pivots) as a hash keyed by both the Solr field name and/or by the blacklight field name



91
92
93
# File 'lib/blacklight/solr/response/facets.rb', line 91

def aggregations
  @aggregations ||= {}.merge(facet_field_aggregations).merge(facet_query_aggregations).merge(facet_pivot_aggregations)
end

#facet_countsObject



95
96
97
# File 'lib/blacklight/solr/response/facets.rb', line 95

def facet_counts
  @facet_counts ||= self['facet_counts'] || {}
end

#facet_fieldsObject

Returns the hash of all the facet_fields (ie: { 'instock_b' => ['true', 123, 'false', 20] }



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/blacklight/solr/response/facets.rb', line 100

def facet_fields
  @facet_fields ||= begin
    val = facet_counts['facet_fields'] || {}

    # this is some old solr (1.4? earlier?) serialization of facet fields
    if val.is_a? Array
      Hash[val]
    else
      val
    end
  end
end

#facet_pivotObject

Returns all of the facet queries



119
120
121
# File 'lib/blacklight/solr/response/facets.rb', line 119

def facet_pivot
  @facet_pivot ||= facet_counts['facet_pivot'] || {}
end

#facet_queriesObject

Returns all of the facet queries



114
115
116
# File 'lib/blacklight/solr/response/facets.rb', line 114

def facet_queries
  @facet_queries ||= facet_counts['facet_queries'] || {}
end