class Queries::NestedQueryBuilder
Constants
- NAME
Attributes
inner_query[R]
path[R]
score_mode[R]
Public Class Methods
new(path:, inner_query:, score_mode: nil, type: :query)
click to toggle source
@params:
path: The query path points to the nested object path. score_mode: The score_mode allows to set how inner children matching affects scoring of parent. It defaults to avg, but can be sum, min, max and none. inner_query: query includes the query that will run on the nested docs matching the direct path, and joining with the root parent docs
Any fields referenced inside the query must use the complete path (fully qualified)
# File lib/queries/nested_query_builder.rb, line 22 def initialize path:, inner_query:, score_mode: nil, type: :query @path = path @inner_query = inner_query @score_mode = score_mode.score_mode if score_mode.present? @type = type end
Public Instance Methods
inner_query_expr()
click to toggle source
returns inner_query
# File lib/queries/nested_query_builder.rb, line 45 def inner_query_expr return @inner_query end
path_expr()
click to toggle source
returns path
# File lib/queries/nested_query_builder.rb, line 40 def path_expr return @path end
query()
click to toggle source
# File lib/queries/nested_query_builder.rb, line 29 def query query = {} nested_query = self.common_query nested_query[:path] = @path if @path.present? nested_query[@type] = @inner_query.query if @inner_query.present? nested_query[:score_mode] = @score_mode if @score_mode.present? query[name.intern] = nested_query return query end
score_mode_expr()
click to toggle source
returns score_mode
# File lib/queries/nested_query_builder.rb, line 50 def score_mode_expr return @score_mode end