curl -H "Content-Type: application/json" -XPOST 'https://mydomain/' -d @cps_index.json
JSON文件中的内容
{
"settings": {
"mappings": {
"_source": {
"enabled": false
},
"cps": {
"properties": {
"firstName": {
"type": "text"
},
"lastname": {
"type": "text"
},
"email": {
"type": "text"
},
"mobileNumber": {
"type": "keyword"
},
"employeeId": {
"type": "keyword"
}
}
}
}
}
}
失败,响应消息为{“error”:“uri [/]和方法[POST]的HTTP方法不正确,允许:[GET,HEAD,DELETE]”,“状态”:405}
最佳答案
几个问题:
mappings
嵌套在settings
中改为这样做:
像这样修改cps_index.json:
{
"mappings": {
"doc": {
"_source": {
"enabled": false
},
"properties": {
"firstName": {
"type": "text"
},
"lastname": {
"type": "text"
},
"email": {
"type": "text"
},
"mobileNumber": {
"type": "keyword"
},
"employeeId": {
"type": "keyword"
}
}
}
}
}
运行这个:
curl -H "Content-Type: application/json" -XPUT 'https://mydomain/indexname'
^ ^
| |
use PUT add index name
关于elasticsearch - Elasticsearch创建索引-失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56083315/