The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true.
时间: 2024-05-05 15:17:16 浏览: 17
This error message typically occurs when trying to create a mapping for Elasticsearch 7.x or later, which requires the use of the `_doc` type instead of explicit types like `tweet` or `user`. To resolve this error, you can either set `include_type_name` to `true` in your mapping definition, or remove any references to explicit types and use `_doc` as the default type.
For example, if you were previously using a mapping like this:
```
PUT my_index
{
"mappings": {
"tweet": {
"properties": {
"message": {
"type": "text"
}
}
}
}
}
```
You would need to update it to use `_doc` instead:
```
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"message": {
"type": "text"
}
}
}
}
}
```
Alternatively, you could add `include_type_name: true` to your mapping definition:
```
PUT my_index
{
"mappings": {
"include_type_name": true,
"tweet": {
"properties": {
"message": {
"type": "text"
}
}
}
}
}
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)