Class: Queries::NestedQueryBuilder
- Inherits:
-
QueryBuilder
- Object
- QueryBuilder
- Queries::NestedQueryBuilder
- Defined in:
- lib/queries/nested_query_builder.rb
Constant Summary collapse
- NAME =
"nested"
Instance Attribute Summary collapse
-
#inner_query ⇒ Object
readonly
Returns the value of attribute inner_query.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#score_mode ⇒ Object
readonly
Returns the value of attribute score_mode.
Instance Method Summary collapse
-
#initialize(path:, inner_query:, score_mode: nil, type: :query) ⇒ NestedQueryBuilder
constructor
@params: path: The query path points to the nested object path.
-
#inner_query_expr ⇒ Object
returns inner_query.
-
#path_expr ⇒ Object
returns path.
- #query ⇒ Object
-
#score_mode_expr ⇒ Object
returns score_mode.
Methods inherited from QueryBuilder
Methods included from AttributesReader
Methods included from AbstractQueryBuilder
Constructor Details
#initialize(path:, inner_query:, score_mode: nil, type: :query) ⇒ NestedQueryBuilder
@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)
22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
#inner_query ⇒ Object (readonly)
Returns the value of attribute inner_query.
11 12 13 |
# File 'lib/queries/nested_query_builder.rb', line 11 def inner_query @inner_query end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/queries/nested_query_builder.rb', line 11 def path @path end |
#score_mode ⇒ Object (readonly)
Returns the value of attribute score_mode.
11 12 13 |
# File 'lib/queries/nested_query_builder.rb', line 11 def score_mode @score_mode end |
Instance Method Details
#inner_query_expr ⇒ Object
returns inner_query
45 46 47 |
# File 'lib/queries/nested_query_builder.rb', line 45 def inner_query_expr return @inner_query end |
#path_expr ⇒ Object
returns path
40 41 42 |
# File 'lib/queries/nested_query_builder.rb', line 40 def path_expr return @path end |
#query ⇒ Object
29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
returns score_mode
50 51 52 |
# File 'lib/queries/nested_query_builder.rb', line 50 def score_mode_expr return @score_mode end |