Class: ElasticsearchDslBuilder::DSL::Search::Queries::Ids
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/queries/ids.rb
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#initialize(values = nil) ⇒ Ids
constructor
A new instance of Ids.
- #to_hash ⇒ Object
- #type(*types) ⇒ Object
- #values(*values) ⇒ Object
Constructor Details
#initialize(values = nil) ⇒ Ids
Returns a new instance of Ids.
6 7 8 9 10 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/ids.rb', line 6 def initialize(values = nil) @type = :ids values(values) super() end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 31 32 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/ids.rb', line 28 def to_hash @query = { values: @values } @query.update(type: @types) if @types super end |
#type(*types) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/ids.rb', line 12 def type(*types) types = types.flatten types_valid = !types.empty? && types.all? { |f| f.instance_of?(String) } raise ArgumentError, 'must pass at least 1 String type' unless types_valid @types ||= [] @types.concat types self end |
#values(*values) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/ids.rb', line 21 def values(*values) values = values.flatten raise ArgumentError, 'values must be a non-empty Array' if values.empty? || values.any?(&:nil?) @values = values self end |