我是Elasticsearch的新手。我们正在使用Elasticsearch 5.0.1,我正在尝试创建索引,如下所示。我确实在这里查看了弹性搜索和一些帖子的文档,但是无法使用以下所需的设置创建索引
PUT testv2
{
"settings": {
"index": {
"number_of_shards": "5",
"analysis": {
"filter": {
"nGram_filter": {
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
],
"min_gram": "2",
"type": "nGram",
"max_gram": "20"
}
},
"analyzer": {
"nGram_analyzer": {
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
],
"type": "custom",
"tokenizer": "whitespace"
},
"whitespace_analyzer": {
"filter": [
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "whitespace"
},
"autocomplete": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "standard"
},
"analyzer_startswith": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
},
"tokenizer": {
"autosuggest_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10,
"token_chars": [
"letter",
"digit"
]
}
}
},
"number_of_replicas": "1"
}
},
"mappings": {
"sample": {
"_all": {
"analyzer": "nGram_analyzer"
},
"properties": {
"sample_description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"sample_type": {
"type": "keyword",
"index": true
},
"sample": {
"type": "keyword",
"index": true,
"analyzer": "autocomplete",
"search_analyzer": "analyzer_startswith"
},
"sample1": {
"type": "keyword",
"index": true,
"analyzer": "autocomplete",
"search_analyzer": "analyzer_startswith"
}
}
}
}
}
但我收到以下错误,请你帮我解决一下。
{
"error": {
"root_cause": [{
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [sample1] has unsupported parameters: [search_analyzer : analyzer_startswith] [analyzer : autocomplete]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [sample]: Mapping definition for [sample1] has unsupported parameters: [search_analyzer : analyzer_startswith] [analyzer : autocomplete]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [sample1] has unsupported parameters: [search_analyzer : analyzer_startswith] [analyzer : autocomplete]"
}
},
"status": 400
}
答案 0 :(得分:0)
keyword
类型不支持分析器。将类型更改为text
,您应该很高兴。