Class: JayAPI::Elasticsearch::QueryBuilder::QueryClauses::QueryString

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

Overview

Represents a Query String query in Elasticsearch Documentation for this type of query can be found here: www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query:, fields: nil) ⇒ QueryString



21
22
23
24
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/query_string.rb', line 21

def initialize(query:, fields: nil)
  @fields = fields ? Array.wrap(fields) : nil
  @query = query
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



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

def fields
  @fields
end

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

#to_hHash



28
29
30
31
32
33
34
# File 'lib/jay_api/elasticsearch/query_builder/query_clauses/query_string.rb', line 28

def to_h
  {
    query_string: {
      query: query
    }.merge(fields_attribute)
  }
end