Class: Sunspot::Query::QueryFieldFacet

Inherits:
QueryFacet
  • Object
show all
Defined in:
lib/sunspot/query/query_field_facet.rb

Overview

QueryFieldFacets are used for the “restricted field facet” feature, which allows an :only parameter for field facets, specifying a set of values in which the searcher is interested. Since Solr does not support this feature directly in field facets, build query facets that replicate field facet behavior.

Instance Attribute Summary

Attributes inherited from QueryFacet

#field, #name, #options

Instance Method Summary collapse

Methods inherited from QueryFacet

#add_row, #rows, #to_params

Constructor Details

#initialize(field, values, options) ⇒ QueryFieldFacet

:nodoc:



11
12
13
14
15
16
17
# File 'lib/sunspot/query/query_field_facet.rb', line 11

def initialize(field, values, options)
  super(field.name, options)
  @field = field
  values.each do |value|
    add_row(value).add_component(Restriction::EqualTo.new(field, value))
  end
end