Class: Queries::ConstantScoreQueryBuilder

Inherits:
QueryBuilder show all
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

Methods inherited from QueryBuilder

#boost

Methods included from AttributesReader

#attributes

Methods included from AbstractQueryBuilder

#do_equals?, #name

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

#queryHash

Returns serialized json query for the object.

Returns:

  • (Hash)

    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