[英]How to create an index in Elasticsearch with an analyzer and shard defined?
我正在嘗試使用定義了分析器的文本和關鍵字的映射來創建索引,這是我迄今為止所嘗試的:
{
"settings" : {
"number_of_shards" : 2,
"number_of_replicas" : 1
},
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": [],
"filter": ["lowercase", "asciifolding"]
}
}
}
,
"mappings": {
"properties": {
"question": {
"type":"text",
"fields": {
"keyword": {
"type": "keyword"
},
"normalize": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
}
}
我試過這個但得到錯誤:
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [analysis] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [analysis] for create index"
},
"status": 400
}
問題是我需要添加此映射的字段。 我正在 AWS ES 服務中嘗試這個。
很好的開始,你就快到了!
analysis
部分需要位於頂級settings
部分內,如下所示:
{
"settings": {
"index": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": [],
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
},
"mappings": {
"properties": {
"question": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
},
"normalize": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
},
"answer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
},
"normalize": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.