Dir*_*irk 23 mapping nested elasticsearch
我尝试将一些嵌套文档索引到Elasticsearch(v2.3.1)映射中,该映射如下所示(基于文档中的此示例):
PUT /my_index
{
"mappings": {
"blogpost": {
"properties": {
"title": { "type": "string" },
"comments": {
"type": "nested",
"properties": {
"name": { "type": "string" },
"comment": { "type": "string" }
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我不明白我的JSON文档必须是什么才能适应该映射.我试过了
PUT /my_index/some_type/1
{
"title": "some_title",
"comments": {
"name": "some_name",
"comment": "some_comment"
}
}
Run Code Online (Sandbox Code Playgroud)
以及
PUT /my_index_some_type/1
{
"title": "some_title",
"comments": [
{
"name": "some_name",
"comment": "some_comment"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这两者都导致了
{
"error":
{
"root_cause":
[
{
"type": "remote_transport_exception",
"reason": "[Caiman][172.18.0.4:9300][indices:data/write/index[p]]"
}
],
"type": "illegal_argument_exception",
"reason": "object mapping [comments] can't be changed from nested to non-nested"
},
"status": ?400
}
Run Code Online (Sandbox Code Playgroud)
索引嵌套文档的格式是正确的?非常感谢任何工作示例,此处SO或其他页面上的大多数示例都集中在嵌套查询上,而不是之前如何对文档编制索引.
Val*_*Val 19
看起来你真的在创建一个类型的文档,some_type并且comments默认为普通文件object(即不是nested),这是不允许的,因为你已经有一个在同一索引comments中的blogpost映射类型中调用的嵌套对象.
试试这个,它应该工作:
PUT /my_index/blogpost/1
{
"title": "some_title",
"comments": {
"name": "some_name",
"comment": "some_comment"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14351 次 |
| 最近记录: |