我使用 gem Chewy 的 elasticsearch。我使用 Globalize gem 进行翻译。我有一个模型位置,并翻译位置的属性名称。但是耐嚼只更新最后的数据,不更新不同语言环境的数据。我想咀嚼更新两个数据(使用语言环境:en,:fr,..)如何在elasticsearch中设置或配置全球化
在文件 location_index.rb
class LocationsIndex < Chewy::Index
settings analysis: {
analyzer: {
folding: {
tokenizer: "standard",
filter: [ "lowercase", "asciifolding" ]
},
sorted: {
tokenizer: 'keyword',
filter: ['lowercase', 'asciifolding']
}
}
}
define_type Location do
field :name, type: 'string', analyzer: 'standard' do
field :folded, type: 'string', analyzer: "folding"
end
field :location, type: 'geo_point', value: ->{ {lat: lat, lon: lon} }
end
define_type Place do
field :name, type: 'string', analyzer: 'standard' do
field :folded, type: 'string', analyzer: "folding"
end
field :address, type: 'string', analyzer: 'standard' do
field :address, type: 'string', analyzer: 'folding'
end
field :category, index: 'not_analyzed', value: ->{ category.name if category.present?}
field :location, type: 'geo_point', value: ->{ {lat: lat, lon: lon} }
end
end