Class: JayAPI::Elasticsearch::QueryBuilder::Script
- Inherits:
-
Object
- Object
- JayAPI::Elasticsearch::QueryBuilder::Script
- Defined in:
- lib/jay_api/elasticsearch/query_builder/script.rb
Overview
Represents a scripted element in a query. This scripted element can be used in different places. It can be used in a query clause, but can also be used to create custom aggregations.
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source:, lang: 'painless', params: nil) ⇒ Script
constructor
A new instance of Script.
-
#to_h ⇒ Hash
The hash representation of the scripted element.
Constructor Details
#initialize(source:, lang: 'painless', params: nil) ⇒ Script
Returns a new instance of Script.
16 17 18 19 20 21 22 23 |
# File 'lib/jay_api/elasticsearch/query_builder/script.rb', line 16 def initialize(source:, lang: 'painless', params: nil) @source = source @lang = lang # Keeps the parameters from being modified from the outside after the # class has been initialized. @params = params.dup.freeze end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
10 11 12 |
# File 'lib/jay_api/elasticsearch/query_builder/script.rb', line 10 def lang @lang end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/jay_api/elasticsearch/query_builder/script.rb', line 10 def params @params end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/jay_api/elasticsearch/query_builder/script.rb', line 10 def source @source end |
Instance Method Details
#to_h ⇒ Hash
Returns The hash representation of the scripted element.
26 27 28 29 30 31 32 |
# File 'lib/jay_api/elasticsearch/query_builder/script.rb', line 26 def to_h { source: source, lang: lang, params: params }.compact end |