elasticsearch - 在 ElasticSearch 中映射未知数量的嵌套对象
问题描述
给定以下嵌套对象
{
"nestedParent":{
"type":"nested",
"dynamic":"true",
"properties":{
...
}
}
}
我也需要它的所有属性都属于该nested
类型。如何为未知数量的嵌套子级生成映射?
功能上等于:
{
"nestedParent":{
"type":"nested",
"dynamic":"true",
"properties":{
"nestedChild1":{
"type":"nested",
"dynamic":"true",
"properties":{
...
}
},
"nestedChild2":{
"type":"nested",
"dynamic":"true",
"properties":{
...
}
},
"nestedChild3":{
"type":"nested",
"dynamic":"true",
"properties":{
...
}
},
...
}
}
}
我确实知道嵌套子项的结构,但我不知道他们的键/名称。
解决方案
您将需要一些通用数据结构,例如 Map of Maps 来映射未知结构。在 Java 中,有很多针对这个问题的实现。例如,请看这篇文章,它描述了如何使用杰克逊映射器处理(反)序列化未知 json:https ://www.baeldung.com/jackson-json-node-tree-model
推荐阅读
- google-chrome - Firefox/Chrome 无法连接到 VMWare Guest 上的站点
- python - Flask 应用程序 MySQLdb 的 Docker 构建错误
- angularjs - loopbackjs 和 Angular 材质
- ruby - 使用 Nokigiri (RUBY) 解析 XML 文件
- elasticsearch - 无法在弹性搜索中更新映射
- gdb - GDB:防止使用“加载”命令加载一节
- python - 这个在 Jupyter notebook 中带有 markdown 的特殊数学表达式
- javascript - 使用 Bootstrap 控制这种效果的 CSS 属性是什么?
- c++ - 为什么 pmr::string 在这些基准测试中这么慢?
- python-3.x - 如何确保每个 gRPC 流都更新一次并避免竞争条件?