【发布时间】:2015-09-10 23:54:45
【问题描述】:
我正在像这样在弹性搜索中存储对象
{
"user":{
"name":"Johnson",
"age":24
}
}
请注意,我没有在 elasticsearch 中设置默认映射。我只是直接插入数据。
现在, 同时使用“嵌套查询”尝试查询数据。
GET user_index/user_document/_search
{
"query":{
"nested" : {
"path" : "user",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"match" : {"user.name" : "Johnson"}
}
]
}
}
}
}
}
这失败了,我得到一个错误
nested object under path [user] is not of nested type
我的问题是
- 是否应该为查询嵌套对象创建默认映射?
-
为什么不能使用下面这样的查询(哪个有效)?
GET user_index/_search { "query":{ "match":{ "user.name":"Johnson" } } }
【问题讨论】:
标签: elasticsearch