elasticsearch - 显示弹性搜索结果时如何将_index和_type分组到_source的父级
问题描述
假设我需要像下面那样查询多个索引和文档,我想将 _source 元素分组到他们自己的 _index,_type 作为父级,但不知何故,它给了每个索引,每个块的类型,我很难管理结果
GET /index_1,index_2,hockey,bookdb_index/_search?size=200
{
"_index": "hockey",
"_type": "player",
"_id": "10",
"_score": 1,
"_source": {
"first": "mikael",
"last": "backlund",
"goals": [
3,
15,
13
],
...
}
},
{
"_index": "bookdb_index",
"_type": "book",
"_id": "2",
"_score": 1,
"_source": {
"title": "Taming Text:...
}
},
如何将索引和类型分组为父元素,而 _source 是子元素
"hockey": {
"player": [{
"first": "mikael",
"last": "backlund",
"goals": [
3,
15,
13
] }
}, { "first": ...
}]
},
"bookdb_index": { ...
解决方案
我为此目的创建了客户端等。
它是在 nginx.conf 中编写的纯弹性搜索查询,上游到弹性服务器,您可以选择index_docs
获得您想要的结果。有关更多信息,请参阅自述文件。
location /test {
elastic_pass http://elastic_upstream;
elastic_send POST /testindex/testdoc/_search?size=100 index_docs;
elastic_query '{"query":
{
"match_all": {}
}
}';
}
推荐阅读
- reactjs - TypeError:ionRouterOutlet.commit 不是函数
- python-3.x - 计算图子集的最短路径
- java - 通过 JNA 发送用户定义的 Windows 消息
- powershell - 如何在powershell格式表中显示行号或行号
- javascript - 如何修复“查询中接受的正文参数”?
- c# - 在 ListBox 中实现 Selectable 用户控件
- css - 使用其他框架(如 Materialise)时,如何在 Bootstrap Navbar Toggler Icon 处于活动状态时更改其背景颜色?
- odoo - Odoo 模块的菜单根目录未显示
- javascript - 尝试将 .php 页面连接到在与 PHP 页面不同的端口上运行的套接字服务器
- html - 标头 html 错误