Class: JayAPI::Elasticsearch::QueryBuilder::QueryClauses::QueryString
- Inherits:
-
QueryClause
- Object
- QueryClause
- JayAPI::Elasticsearch::QueryBuilder::QueryClauses::QueryString
- 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
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
-
#initialize(query:, fields: nil) ⇒ QueryString
constructor
A new instance of QueryString.
-
#to_h ⇒ Hash
The Hash that represents this query (in Elasticsearch’s format).
Constructor Details
#initialize(query:, fields: nil) ⇒ QueryString
Returns a new instance of 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
#fields ⇒ Object (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 |
#query ⇒ Object (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_h ⇒ Hash
Returns The Hash that represents this query (in Elasticsearch’s format).
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 |