class Estella::Parser
Public Class Methods
new(model)
click to toggle source
# File lib/estella/parser.rb, line 3 def initialize(model) @model = model end
Public Instance Methods
boost(name, opts = {})
click to toggle source
document level boost @see www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html
# File lib/estella/parser.rb, line 9 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 @model.field_boost = { boost: { field: name }.merge(opts) } end
field(name, opts = {})
click to toggle source
index a field
# File lib/estella/parser.rb, line 17 def field(name, opts = {}) using = opts[:using] || name analysis = opts[:analysis] & @model.default_analysis_fields.keys opts[:fields] ||= Hash[analysis.zip(@model.default_analysis_fields.values_at(*analysis))] if analysis include_raw = opts.delete(:include_raw) opts[:fields][:raw] = { type: 'keyword' } if include_raw @model.indexed_json.merge!(name => using) @model.indexed_fields.merge!(name => opts) end