Class: Solr::Query::Request::Facet
- Inherits:
-
Object
- Object
- Solr::Query::Request::Facet
- Includes:
- Support::SchemaHelper
- Defined in:
- lib/solr/query/request/facet.rb
Constant Summary collapse
- TERMS_TYPE =
:terms
- QUERY_TYPE =
:query
- RANGE_TYPE =
:range
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#gap ⇒ Object
readonly
Returns the value of attribute gap.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#lower_bound ⇒ Object
readonly
Returns the value of attribute lower_bound.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#subfacets ⇒ Object
readonly
Returns the value of attribute subfacets.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#upper_bound ⇒ Object
readonly
Returns the value of attribute upper_bound.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(field:, type:, name: nil, value: nil, filters: [], subfacets: [], options: {}) ⇒ Facet
constructor
A new instance of Facet.
- #to_solr_h ⇒ Object
Methods included from Support::SchemaHelper
Constructor Details
#initialize(field:, type:, name: nil, value: nil, filters: [], subfacets: [], options: {}) ⇒ Facet
Returns a new instance of Facet.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/solr/query/request/facet.rb', line 23 def initialize(field:, type:, name: nil, value: nil, filters: [], subfacets: [], options: {}) if [:limit].nil? && type == TERMS_TYPE raise ArgumentError, "Need to specify :limit option value for 'terms' facet type" end if .values_at(:gap, :lower_bound, :upper_bound).any?(&:nil?) && type == RANGE_TYPE raise ArgumentError, "Need to specify :lower_bound, :upper_bound, :gap option values for 'range' facet type" end @field = field @name = name || field @type = type @value = value @filters = filters @subfacets = subfacets @limit = [:limit].to_i @gap = [:gap] @lower_bound = [:lower_bound] @upper_bound = [:upper_bound] @domain = [:domain] end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def domain @domain end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def field @field end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def filters @filters end |
#gap ⇒ Object (readonly)
Returns the value of attribute gap.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def gap @gap end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def limit @limit end |
#lower_bound ⇒ Object (readonly)
Returns the value of attribute lower_bound.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def lower_bound @lower_bound end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def name @name end |
#subfacets ⇒ Object (readonly)
Returns the value of attribute subfacets.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def subfacets @subfacets end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def type @type end |
#upper_bound ⇒ Object (readonly)
Returns the value of attribute upper_bound.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def upper_bound @upper_bound end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/solr/query/request/facet.rb', line 11 def value @value end |
Instance Method Details
#to_solr_h ⇒ Object
45 46 47 48 49 |
# File 'lib/solr/query/request/facet.rb', line 45 def to_solr_h return { name.to_s => value } if type == QUERY_TYPE && value default_solr_h end |