【发布时间】:2017-12-07 03:11:38
【问题描述】:
例如,我想在 myindex/mytype 中插入一个包含 两个 字符串的新文档
{ "name" : "joe", "city": "ny" }
但 mytype 仅包含 一个 字符串字段:“name”
在这种情况下,我希望索引失败,并且 elasticsearch 将返回错误。我怎么做? 现在,它创建了一个新文档:皱眉:
感谢您的帮助!
【问题讨论】:
标签: elasticsearch
例如,我想在 myindex/mytype 中插入一个包含 两个 字符串的新文档
{ "name" : "joe", "city": "ny" }
但 mytype 仅包含 一个 字符串字段:“name”
在这种情况下,我希望索引失败,并且 elasticsearch 将返回错误。我怎么做? 现在,它创建了一个新文档:皱眉:
感谢您的帮助!
【问题讨论】:
标签: elasticsearch
您可以使用映射的dynamic 设置。
PUT /my_index
{
"mappings": {
"my_type": {
"dynamic": "strict",
"properties": {
"name": { "type": "string"}
}
}
}
}
来源:https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html
【讨论】: