class Queries::DisMaxQueryBuilder
A query that generates the union of documents produced by its sub-queries, and that scores each document with the maximum score for that document as produced by any sub-query, plus a tie breaking increment for any additional matching sub-queries.
Constants
- DEFAULT_TIE_BREAKER
@!visibility protected
- NAME
@!visibility protected
Public Class Methods
new()
click to toggle source
# File lib/queries/dis_max_query_builder.rb, line 15 def initialize @queries = [] @tie_breaker = DEFAULT_TIE_BREAKER end
Public Instance Methods
add(query)
click to toggle source
@params [QueryBuilder] query subquery to be added to the dismax query add a sub-query to this disjunction @return [DisMaxQueryBuilder]
modified self
# File lib/queries/dis_max_query_builder.rb, line 63 def add(query) raise 'Query for Dismax is nil' if query.nil? @queries.append(query) self end
inner_queries_expr()
click to toggle source
an immutable list copy of the current sub-queries of this disjunction @!visibilty protected
# File lib/queries/dis_max_query_builder.rb, line 31 def inner_queries_expr @queries end
query()
click to toggle source
# File lib/queries/dis_max_query_builder.rb, line 20 def query query = {} dm_query = common_query dm_query[:queries] = @queries.map(&:query) if @queries.present? dm_query[:tie_breaker] = @tie_breaker query[name.intern] = dm_query query end
tie_breaker(value)
click to toggle source
@params [Numeric] value tie_breaker
value
tie_breaker: the score of each non-maximum disjunct for a document is multiplied by this weight and added into the final score. If non-zero, the value should be small, on the order of 0.1, which says that 10 occurrences of word in a lower-scored field that is also in a higher scored field is just as good as a unique word in the lower scored field (i.e., one that is not in any higher scored field).
adds the tie_breaker
value @return [DisMaxQueryBuilder]
modified self
# File lib/queries/dis_max_query_builder.rb, line 52 def tie_breaker(value) raise 'Tie Breaker value is nil' if value.nil? @tie_breaker = value self end
tie_breaker_expr()
click to toggle source
returns the tie breaker value @!visibility protected
# File lib/queries/dis_max_query_builder.rb, line 37 def tie_breaker_expr @tie_breaker end