Class: Solr::Query::Request::Filter
- Inherits:
-
Object
- Object
- Solr::Query::Request::Filter
- Includes:
- Support::SchemaHelper
- Defined in:
- lib/solr/query/request/filter.rb
Constant Summary collapse
- EQUAL_TYPE =
:equal
- NOT_EQUAL_TYPE =
:not_equal
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type:, field:, value:) ⇒ Filter
constructor
A new instance of Filter.
- #solr_field ⇒ Object
- #solr_value ⇒ Object
- #to_solr_s ⇒ Object
Methods included from Support::SchemaHelper
Constructor Details
#initialize(type:, field:, value:) ⇒ Filter
Returns a new instance of Filter.
14 15 16 17 18 |
# File 'lib/solr/query/request/filter.rb', line 14 def initialize(type:, field:, value:) @type = type @field = field @value = value end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
12 13 14 |
# File 'lib/solr/query/request/filter.rb', line 12 def field @field end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/solr/query/request/filter.rb', line 12 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
12 13 14 |
# File 'lib/solr/query/request/filter.rb', line 12 def value @value end |
Instance Method Details
#solr_field ⇒ Object
24 25 26 |
# File 'lib/solr/query/request/filter.rb', line 24 def solr_field solarize_field(@field) end |
#solr_value ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/solr/query/request/filter.rb', line 28 def solr_value if value.is_a?(::Array) value.map { |v| to_primitive_solr_value(v) }.join(' OR ') elsif value.is_a?(::Range) to_interval_solr_value(value) else to_primitive_solr_value(value) end end |
#to_solr_s ⇒ Object
20 21 22 |
# File 'lib/solr/query/request/filter.rb', line 20 def to_solr_s "#{solr_prefix}#{solr_field}:(#{solr_value})" end |