Class: JayAPI::Elasticsearch::QueryBuilder::QueryClauses::Exists

Inherits:
QueryClause
  • Object
show all
Defined in:
lib/jay_api/elasticsearch/query_builder/query_clauses/exists.rb

Overview

Represents an Exists query Documentation for this type of query can be found here: www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:) ⇒ Exists

Returns a new instance of Exists.

Parameters:

  • field (String, Symbol)

    The name of the field.



16
17
18
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/exists.rb', line 16

def initialize(field:)
  @field = field
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



13
14
15
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/exists.rb', line 13

def field
  @field
end

Instance Method Details

#to_hHash

Returns The Hash representation of the Query Clause (in Elasticsearch’s format).

Returns:

  • (Hash)

    The Hash representation of the Query Clause (in Elasticsearch’s format)



22
23
24
25
26
27
28
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/exists.rb', line 22

def to_h
  {
    exists: {
      field: field
    }
  }
end