Elasticsearch中如何保存嵌套JSON数据类型
在Elasticsearch中,可以使用'nested'数据类型来保存这种类型的数据。
下面是一个示例的映射定义:
PUT my_index
{
"mappings": {
"properties": {
"sourceJSON": {
"type": "nested",
"properties": {
"6bc64cba8c4b1c9e2557ce4a3c86fef0": {
"type": "object",
"properties": {
"sourceId": {
"type": "keyword"
}
}
},
"272d6d8eae79cf7d389827e5d62cdd2a": {
"type": "object",
"properties": {
"sourceId": {
"type": "keyword"
},
"title": {
"type": "text"
}
}
}
}
}
}
}
}
这样,你就可以将这个数据类型保存到Elasticsearch中,并使用nested查询来查询或过滤这些数据。
原文地址: http://www.cveoy.top/t/topic/lhBT 著作权归作者所有。请勿转载和采集!