嵌套和父子类型查询2.0

一、嵌套类型查询Nested

 1 #city为包含北京市  或者  包含太谷区的  省份信息
 2 GET product/_search
 3 {
 4   "query": {
 5     "nested": {
 6       "path": "province",
 7       "query": {
 8         "nested": {
 9           "path": "province.cities",
10           "query": {
11             "bool": {
12               "should": [
13                 {
14                   "match": {
15                     "province.cities.name": "北京市"
16                   }
17                 },
18                 {
19                   "nested": {
20                     "path": "province.cities.district",
21                     "query": {
22                       "bool": {
23                         "must": [
24                           {
25                             "match": {
26                               "province.cities.district.name": "太谷区"
27                             }
28                           }
29                         ]
30                       }
31                     }
32                   }
33                 }
34               ]
35             }
36           }
37         }
38       }
39     }
40   }
41 }

二、父子级关系

 

作者:http://cnblogs.com/lyc-code/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权力。

原文地址:https://www.cnblogs.com/lyc-code/p/15261953.html