Sha256: 664afbf8ad002b8d0b9671b014cd6c4e41902b26e796bbfdda78fe39ff83d395
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
module AxleAttributes class Definition module Indexed def index options[:index] end ANALYZERS = [:snowball, :proper_noun, :simple] def analyzer_mapping {type: 'string', analyzer: index} if ANALYZERS.include?(index) end INDEXES_BY_TYPE = { array: {type: "string", index: "not_analyzed", doc_values: true}, boolean: {type: "boolean", doc_values: true}, float: {type: "double", doc_values: true}, integer: {type: "long", doc_values: true}, json: {type: "boolean"}, string: {type: 'string', index_analyzer: 'keyword', search_analyzer: 'standard'}, text: {type: 'string', index_analyzer: 'keyword', search_analyzer: 'standard'}, time: {type: "date", format: "dateOptionalTime", doc_values: true}, date: {type: "date", format: "date", doc_values: true} } def index_mapping return unless index if mapping = analyzer_mapping multi_field_index(name, mapping) elsif index == true INDEXES_BY_TYPE[type] || (raise "unknown index type #{type.inspect} for #{name}") elsif index.is_a?(Hash) index end end def multi_field_index(field, analyzer_mapping) {type: "multi_field", fields: {field => {type: "string", index: "not_analyzed", doc_values: true}, analyzed: analyzer_mapping}} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axle_attributes-1.13.2 | lib/axle_attributes/definition/indexed.rb |