Class: ElasticsearchDslBuilder::DSL::Search::Queries::FunctionScore
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
-
#initialize ⇒ FunctionScore
constructor
A new instance of FunctionScore.
- #query(query) ⇒ Object
- #score_mode(score_mode) ⇒ Object
- #script_score(script) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ FunctionScore
Returns a new instance of FunctionScore.
6 7 8 9 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb', line 6 def initialize @type = :function_score super() end |
Instance Method Details
#query(query) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb', line 11 def query(query) raise ArgumentError, 'query must extend type Queries::Query' unless query.is_a?(Query) @nested_query = query.to_hash self end |
#score_mode(score_mode) ⇒ Object
18 19 20 21 22 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb', line 18 def score_mode(score_mode) raise ArgumentError, 'score_mode must be a String' unless score_mode.instance_of?(String) @score_mode = score_mode self end |
#script_score(script) ⇒ Object
24 25 26 27 28 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb', line 24 def script_score(script) raise ArgumentError, 'script must be a String' unless script.instance_of?(String) @script = script self end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/function_score.rb', line 30 def to_hash @query = {} @query.update(query: @nested_query) if @nested_query @query.update(score_mode: @score_mode) if @score_mode @query.update(script_score: { script: @script }) if @script super end |