【发布时间】:2020-06-02 22:11:32
【问题描述】:
我有一个包含嵌套字段的文档。示例:
"mappings": {
"blogpost": {
"properties": {
"title": { "type": "text" },
"body": { "type": "text" },
"comments": {
"type": "nested",
"properties": {
"name": { "type": "text" },
"comment": { "type": "text" },
"age": { "type": "short" },
"stars": { "type": "short" },
"date": { "type": "date" }
}
}
}
}
}
}
是否可以修改查询以使响应仅包含非嵌套字段?
在此示例中,响应将仅包含 body 和 title。
使用_source 可以排除/包含字段
GET /blogpost/_search
{
"_source":{
"excludes":["comments"]
}
}
但是您必须明确地将字段名称放在排除中,我正在寻找一种方法来排除所有嵌套字段而不知道它们的字段名称
【问题讨论】:
-
你能显示你现在发送的查询吗?
-
是的,我已经更新了帖子
标签: elasticsearch