lib/estella/parser.rb in estella-5.0.1 vs lib/estella/parser.rb in estella-6.0.0
- old
+ new
@@ -1,15 +1,18 @@
+# frozen_string_literal: true
+
module Estella
class Parser
def initialize(model)
@model = model
end
# document level boost
# @see https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html
def boost(name, opts = {})
- fail ArgumentError, 'Boost field is not indexed!' unless @model.indexed_fields.include? name
- fail ArgumentError, 'Please supply a modifier and a factor for your boost!' unless (opts.keys & %i[modifier factor]).length == 2
+ raise ArgumentError, 'Boost field is not indexed!' unless @model.indexed_fields.include? name
+ raise ArgumentError, 'Please supply a modifier and a factor for your boost!' unless (opts.keys & %i[modifier
+ factor]).length == 2
@model.field_boost = { boost: { field: name }.merge(opts) }
end
# index a field