elasticsearch存入数据嵌入式数据解决扁平化查询问题
嵌套查询搜索嵌套的字段对象,就像它们作为单独的文档被索引一样。如果对象与搜索匹配,嵌套查询将返回根父文档。
官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
1.在创建索引时进行将type标记为‘nested’
PUT product
{
"mappings": {
"properties": {
"catelogName":{
"type": "keyword",
"index": false,
"doc_values": false
},
"attrs":{
"type": "nested",
"properties":{
"attiId":{
"type":"long"
},
"attrName":{
"type":"keyword",
"index": false,
"doc_values": false
},
"attrValue":{
"type":"keyword"
}
}
}
}
}
}
2.修改映射type类型
PUT /my-index-000001
{
"mappings": {
"properties": {
"obj1": {
"type": "nested"
}
}
}
}