我有一個發布到彈性中的模式,我想知道是否可以在發布索引時添加小寫規范化器,以便更新該欄位并避免使用所有舊欄位和新欄位定義新模式物件。
目前我正在嘗試使用以下命令更新該欄位:
await this.getClient().indices.putSettings({index: indexName, body:{
softwarePublisher: {
type: "text",
fields: {
ngram: {
type: "text",
analyzer: "software_analyzer",
search_analyzer: "software_search_analyzer",
},
raw: {
type: "keyword",
},
rawl: {
type: "keyword",
normalizer: "lowercase_normalizer",
},
},
},
}});
但我收到以下錯誤:
{"error":{"root_cause":[{"type":"illegal_argument_exception","re??ason":"unknown setting [index.softwarePublisher.fields.ngram.analyzer] 請檢查是否安裝了任何必需的插件,或檢查已洗掉設定的重大更改檔案"}],"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.ngram.analyzer] 請檢查是否安裝了任何必需的插件,或檢查重大更改已洗掉設定的檔案","suppressed":[{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.ngram.search_analyzer] 請檢查是否安裝了任何必需的插件,或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.ngram.type] 請檢查是否安裝了任何必需的插件,或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.raw.type] 請檢查是否安裝了任何必需的插件,或檢查中斷更改已洗掉設定的檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.rawl.normalizer] 請檢查是否安裝了任何必需的插件,或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.fields.rawl.type] 請檢查是否安裝了任何必需的插件,或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.type] 請檢查是否安裝了任何必需的插件,或檢查已洗掉的重大更改檔案設定"}]},"狀態":400}或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.type] 請檢查是否安裝了任何必需的插件,或檢查重大更改檔案對于已洗掉的設定"}]},"status":400}或檢查已洗掉設定的重大更改檔案"},{"type":"illegal_argument_exception","re??ason":"未知設定 [index.softwarePublisher.type] 請檢查是否安裝了任何必需的插件,或檢查重大更改檔案對于已洗掉的設定"}]},"status":400}
I tried to with putMappings but anyway I got an error.
EDIT
Elastic version
curl -XGET 'http://localhost:9200'
{
"name" : "bf9cd8c528fc",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "MzMfZzJaQwia1A5U5SFzNg",
"version" : {
"number" : "7.1.1",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "7a013de",
"build_date" : "2019-05-23T14:04:00.380842Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
EDIT 2
Error using putMapping
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [publisher : {type=text, fields={rawl={normalizer=lowercase_normalizer, type=keyword}, raw={type=keyword}, ngram={search_analyzer=software_search_analyzer, analyzer=software_analyzer, type=text}}}]"}],"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [publisher : {type=text, fields={rawl={normalizer=lowercase_normalizer, type=keyword}, raw={type=keyword}, ngram={search_analyzer=software_search_analyzer, analyzer=software_analyzer, type=text}}}]"},"status":400}
Analyzer
export const softwareNameAnalyzer = {
filter: {
ngram_custom: {
type: "edge_ngram",
min_gram: "1",
max_gram: "15",
},
},
tokenizer: {
software_tokenizer,
},
normalizer: {
lowercase_normalizer: {
filter: ["lowercase"],
},
},
analyzer: {
software_search_analyzer: defaultAnalyzer,
software_analyzer: softwareAnalyzer,
default: defaultAnalyzer,
default_search: defaultAnalyzer,
},
};
export const softwareAnalyzer = {
type: "custom",
tokenizer: "software_tokenizer",
char_filter: ["html_strip"],
filter: ["lowercase", "ngram_custom"],
};
任何的想法?
謝謝?
uj5u.com熱心網友回復:
首先,您應該使用putMappings()notputSettings()因為您正在定義欄位。
然后您必須putMappings()按如下方式呼叫(您缺少該properties部分):
await this.getClient().indices.putMappings({index: indexName, body:{
properties: { <<----- add this
softwarePublisher: {
...
}
}
}});
注意:您需要確保在呼叫putSettings()之前先putMappings安裝您的自定義分析器,否則putMappings()呼叫會抱怨您的自定義分析器不存在。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/320925.html
