Class: Queries::ConstantScoreQueryBuilder
- Inherits:
-
QueryBuilder
- Object
- QueryBuilder
- Queries::ConstantScoreQueryBuilder
- Defined in:
- lib/queries/constant_score_query_builder.rb
Overview
A query that wraps a filter and simply returns a constant score equal to the query boost for every document in the filter.
Constant Summary collapse
- NAME =
'constant_score'
Instance Method Summary collapse
-
#initialize(inner_query:) ⇒ ConstantScoreQueryBuilder
constructor
A new instance of ConstantScoreQueryBuilder.
-
#query ⇒ Hash
Serialized json query for the object.
Methods inherited from QueryBuilder
Methods included from AttributesReader
Methods included from AbstractQueryBuilder
Constructor Details
#initialize(inner_query:) ⇒ ConstantScoreQueryBuilder
Returns a new instance of ConstantScoreQueryBuilder.
13 14 15 |
# File 'lib/queries/constant_score_query_builder.rb', line 13 def initialize(inner_query:) @inner_query = inner_query end |
Instance Method Details
#query ⇒ Hash
Returns serialized json query for the object.
18 19 20 21 22 23 24 |
# File 'lib/queries/constant_score_query_builder.rb', line 18 def query query = {} cs_query = common_query cs_query[:filter] = @inner_query.query if @inner_query.present? query[name.intern] = cs_query query end |