【发布时间】:2016-07-24 07:21:04
【问题描述】:
所以我尝试在 ElasticSearch 中搜索嵌套对象,但由于没有得到任何结果,所以我没有正确执行某些操作。
我运行以下命令:-
创建索引和映射
PUT /demo
{
"mappings": {
"person": {
"properties": {
"children": {
"type": "nested",
"properties": {
"fullName": {
"type": "string"
},
"gender": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
添加个人文档
POST /demo/person/1
{
"children": [{
"fullName" : "Bob Smith",
"gender": "M"
}]
}
这些都按预期执行。但是,当我按照documentation 中的概述来搜索它们时,我没有得到任何结果。
查询
POST /demo/person/_search
{
"query": {
"bool": {
"must": [{
"match_all": {}
},
{
"nested": {
"path": "children",
"query": {
"bool": {
"must": [{
"match": {
"fullName": "Bob Smith"
}
}]
}
}
}
}]
}
}
}
我做错了什么?
【问题讨论】:
-
你是按 fullName 处理的,但是这个字段在 Lucene 中保存为 children.fullName。只需更改为 children.fullName :)
-
@WaldemarNeto - 谢谢这是问题所在。
标签: elasticsearch elasticsearch-2.0