您快到这里了,只是缺少了一些东西:
PUT /test{ "mappings": { "type_name": { <--- add the type name "properties": { <--- enclose all field definitions in "properties" "field1": { "type": "integer" }, "field2": { "type": "integer" }, "field3": { "type": "string", "index": "not_analyzed" }, "field4,": { "type": "string", "analyzer": "autocomplete", "search_analyzer": "standard" } } } }, "settings": { ... }}更新
如果您的索引已经存在,您还可以像这样修改映射:
PUT test/_mapping/type_name{ "properties": { <--- enclose all field definitions in "properties" "field1": { "type": "integer" }, "field2": { "type": "integer" }, "field3": { "type": "string", "index": "not_analyzed" }, "field4,": { "type": "string", "analyzer": "autocomplete", "search_analyzer": "standard" } }}更新 :
从ES
7开始,已删除映射类型。您可以在这里阅读更多详细信息



