Class: ElasticsearchDslBuilder::DSL::Search::Queries::Exists

Inherits:
Query
  • Object
show all
Defined in:
lib/elasticsearch_dsl_builder/dsl/search/queries/exists.rb

Instance Attribute Summary

Attributes inherited from Query

#query, #type

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ Exists

Returns a new instance of Exists.



6
7
8
9
10
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/exists.rb', line 6

def initialize(field)
  @type = :exists
  field(field)
  super()
end

Instance Method Details

#field(field) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/exists.rb', line 12

def field(field)
  raise ArgumentError, 'field must be a String' unless field.instance_of?(String)
  @field = field
  self
end

#to_hashObject



18
19
20
21
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/exists.rb', line 18

def to_hash
  @query = { field: @field }
  super
end