我有一个名为placess
的类型,如下所示:
"name" : {
"type" : "string"
},
我创建了一个分析器如下:
curl -XPUT 'localhost:9200/ashojash/_settings' -d '{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
}
“
我的问题是如何将此分析器添加到名为name
的现有字段中?
我试过
curl -XPUT 'http://localhost:9200/ashojash/_mapping/venues' -d '
{
"venues" : {
"properties" : {
"name" : {
type:"string",
"analyzer": "persian"
}
}
}
}'
但是这给了我冲突字段[name]已经存在
如何将此分析器添加到名为name
的现有字段中?
答案 0 :(得分:0)
您需要在创建索引的同时执行此操作(在创建后无法将分析器更改为字段):
curl -XPUT 'localhost:9200/ashojash' -d '{
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
},
"mappings": {
"venues": {
"properties": {
"name": {
"type": "string",
"analyzer": "autocomplete"
}
}
}
}
}'