gpt4 book ai didi

ruby-on-rails - 如何使用Ruby on Rails将ElasticSearch从6.8升级到7.X

转载 作者:行者123 更新时间:2023-12-02 19:57:38 31 4
gpt4 key购买 nike

我有一个使用ElasticSearch服务器的Rails应用程序,它们都位于相应的Docker Image中。

我想升级我的ElasticSearch服务器。实际上我正在运行image: docker.elastic.co/elasticsearch/elasticsearch:6.8.1,我想将其更新为7.X
在版本7中,当我重建索引时出现此错误:

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [listing : {dynamic=true, properties={uid={analyzer=id_analyzer, type=text}, bee_id={analyzer=id_analyzer, type=text}, address={analyzer=address_analyzer, type=text}, location={type=geo_point}}}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [listing : {dynamic=true, properties={uid={analyzer=id_analyzer, type=text}, bee_id={analyzer=id_analyzer, type=text}, address={analyzer=address_analyzer, type=text}, location={type=geo_point}}}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [listing : {dynamic=true, properties={uid={analyzer=id_analyzer, type=text}, bee_id={analyzer=id_analyzer, type=text}, address={analyzer=address_analyzer, type=text}, location={type=geo_point}}}]"
}
},
"status": 400
}


我知道错误是由重大更改引起的,但我不知道如何解决。

我正在使用 gem elasticsearch-model:

我的定义如下:
    include Elasticsearch::Model

after_destroy { |record| ElasticIndexer.new(:delete, record.class.name, record.id) }
after_save { ElasticIndexer.new(:index, self.class.name, self.id)}

index_name "#{Rails.application.class.parent_name.underscore}_#{Rails.env} mydoc"
document_type "mydoc"

def as_indexed_json(options={})
[....]
end

settings index: { number_of_shards:5, number_of_replicas:0 } do
settings :analysis => {
char_filter: {
dash_remover: {
type: "mapping",
mappings: ["-=>"]
}
},
filter: {
english_stemmer: {
type: "stemmer",
language: "english"
}
},
tokenizer: {
id_tokenizer: {
type: "ngram",
min_gram: 3,
max_gram: 3,
token_chars: ["letter", "digit"]
},
address_tokenizer: {
type: "edgeNGram",
min_gram: 3,
max_gram: 3,
token_chars: ["letter", "digit"]
}
},
analyzer: {
description_analyzer: {
type: 'custom',
tokenizer: 'standard',
filter: ['asciifolding', 'lowercase']
},
id_analyzer: {
tokenizer: "id_tokenizer",
char_filter: ["dash_remover"],
filter: ['asciifolding', 'lowercase']
},
english_description_analyzer: {
tokenizer: "whitespace",
char_filter: ["html_strip"],
filter: ['asciifolding', 'lowercase', "english_stemmer"]
},
address_analyzer: {
tokenizer: "address_tokenizer",
filter: ['asciifolding', 'lowercase']
},
}
}
mappings dynamic: true do
indexes :location, :type => 'geo_point'
indexes :uid, :analyzer => 'id_analyzer'
indexes :bee_id, :analyzer => 'id_analyzer'
indexes :address, :analyzer => 'address_analyzer'
end
end

我应该应用哪些更改?

最佳答案

最后,我继续前进。很长一段时间后,该回到它了。

看了很多书之后,当我遇到这段微妙的代码行时,我正在查看我的代码

我注释掉了:document_type "mydoc"我试试看。

当控制台没有错误出现时,我感到惊讶!
有用。 (好故事)

关于ruby-on-rails - 如何使用Ruby on Rails将ElasticSearch从6.8升级到7.X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56810211/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com