当前位置:   article > 正文

elasticsearch 父子文档(7.13)_sprinboot注解实现 elasticsearch7父子文档

sprinboot注解实现 elasticsearch7父子文档

elasticsearch 父子文档

             

官网:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/parent-join.html

has parent query:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-has-parent-query.html

has child query:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-has-child-query.html

parent id query:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-parent-id-query.html#parent-id-query-ex-request

children aggregation:https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-aggregations-bucket-children-aggregation.html

                  

                     

********************

join field type

              

join类型在同一个index内创建文档的父子关系

  1. PUT my-index-000001
  2. {
  3. "mappings": {
  4. "properties": {
  5. "my_id": {
  6. "type": "keyword"
  7. },
  8. "my_join_field": {
  9. "type": "join", # my_join_field为join字段
  10. "relations": {
  11. "question": "answer" # question:父文档标识
  12. } # answer:子文档标识
  13. }
  14. }
  15. }
  16. }

                

创建父文档

  1. PUT my-index-000001/_doc/1?refresh
  2. {
  3. "my_id": "1",
  4. "text": "This is a question",
  5. "my_join_field": {
  6. "name": "question"
  7. }
  8. }
  9. # 简化写法
  10. PUT my-index-000001/_doc/2?refresh
  11. {
  12. "my_id": "2",
  13. "text": "This is another question",
  14. "my_join_field": "question"
  15. }

               

创建子文档

  1. PUT my-index-000001/_doc/3?routing=1&refresh
  2. {
  3. "my_id": "3",
  4. "text": "This is an answer",
  5. "my_join_field": {
  6. "name": "answer", # 子文档标识
  7. "parent": "1" # 父文档id
  8. }
  9. }
  10. 说明:routing字段必须,父子文档必须在同一个分片(shard)上

            

性能说明

  1. The join field shouldn’t be used like joins in a relation database.
  2. In Elasticsearch the key to good performance is to de-normalize your
  3. data into documents.
  4. # join字段不应该该像关系型数据库那样使用,从性能方面考虑,可以进行反范式设计
  5. Each join field, has_child or has_parent query adds a significant tax
  6. to your query performance.
  7. # join字段、has_child query、has_parent query都会影响查询性能
  8. The only case where the join field makes sense is if your data contains
  9. a one-to-many relationship where one entity significantly outnumbers
  10. the other entity.
  11. # join字段常用于一对多的关系

               

join 使用限制

  1. Only one join field mapping is allowed per index.
  2. # 同一个index最多只能使用一个join字段
  3. Parent and child documents must be indexed on the same shard.
  4. # 父子文档必须在同一个分片(shard)上
  5. An element can have multiple children but only one parent.
  6. # 一个文档可以有多个子文档,但最多只能有一个父文档
  7. It is possible to add a new relation to an existing join field.
  8. # 可以在join字段中添加新的关联关系(子文档可以成为其他文档的父文档)
  9. It is also possible to add a child to an existing element but
  10. only if the element is already a parent.
  11. # 只能给父文档添加子文档

                

******************

多重父子关联(multiple levels of parent join)

              

                                           

  1. PUT my-index-000001
  2. {
  3. "mappings": {
  4. "properties": {
  5. "my_join_field": {
  6. "type": "join",
  7. "relations": {
  8. "question": ["answer", "comment"],
  9. "answer": "vote"
  10. }
  11. }
  12. }
  13. }
  14. }

 说明:多重父子关联会影响查询性能,不推荐使用,

              

创建文档

  1. # 文档 1
  2. PUT my-index-000001/_doc/1?refresh
  3. {
  4. "my_id": "1",
  5. "text": "This is a question",
  6. "my_join_field": "question"
  7. }
  8. # 文档 2:文档 1的子文档
  9. PUT my-index-000001/_doc/2?routing=1&refresh #routing的值为文档 1的路由id
  10. {
  11. "my_id": "3",
  12. "text": "This is an answer",
  13. "my_join_field": {
  14. "name": "answer",
  15. "parent": "1" # 父文档的id(文档 1)
  16. }
  17. }
  18. # 文档 3:文档 2的子文档
  19. PUT my-index-000001/_doc/3?routing=1&refresh #routing的值为文档 1的路由id
  20. {
  21. "text": "This is a vote",
  22. "my_join_field": {
  23. "name": "vote",
  24. "parent": "2" # 父文档的id(文档 2)
  25. }
  26. }

                   

                      

********************

has parent query

          

查询条件为父文档,查询结果为子文档

  1. # 索引 my-index-000001
  2. PUT /my-index-000001
  3. {
  4. "mappings": {
  5. "properties": {
  6. "my-join-field": {
  7. "type": "join",
  8. "relations": {
  9. "parent": "child"
  10. }
  11. },
  12. "tag": {
  13. "type": "keyword"
  14. }
  15. }
  16. }
  17. }
  18. # 查询条件:父文档tag=Elasticsearch
  19. GET /my-index-000001/_search
  20. {
  21. "query": {
  22. "has_parent": {
  23. "parent_type": "parent",
  24. "query": {
  25. "term": {
  26. "tag": {
  27. "value": "Elasticsearch"
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }

           

相关参数

  1. parent_type:必须,父文档标识
  2. query:必须,搜索匹配的父文档,返回对应的子文档
  3. score:可选,truefalse(默认)
  4. (Optional, Boolean) Indicates whether the relevance score of a
  5. matching parent document is aggregated into its child documents.
  6. false:父文档的score不会计入子文档
  7. true:父文档的score会计入子文档
  8. ignore_unmapped:可选,truefalse(默认)
  9. (Optional, Boolean) Indicates whether to ignore an unmapped
  10. parent_type and not return any documents instead of an error
  11. false:父文档类型不匹配,返回error
  12. true:父文档类型不匹配,不返回error

                 

                         

********************

has child query

            

查询条件为子文档,返回父文档

  1. # 索引:my-index-000001
  2. PUT /my-index-000001
  3. {
  4. "mappings": {
  5. "properties": {
  6. "my-join-field": {
  7. "type": "join",
  8. "relations": {
  9. "parent": "child"
  10. }
  11. }
  12. }
  13. }
  14. }
  15. # 查询条件:最少有2个子文档、最多有10个子文档
  16. GET /_search
  17. {
  18. "query": {
  19. "has_child": {
  20. "type": "child",
  21. "query": {
  22. "match_all": {} #匹配所有子文档
  23. },
  24. "max_children": 10, #最多10个子文档
  25. "min_children": 2, #最少2个子文档
  26. "score_mode": "min" #返回最少得分
  27. }
  28. }
  29. }

                

相关参数

  1. type:必选,子文档标识
  2. query:必选,匹配子文档
  3. ignore_unmapped:可选,truefalse(默认)
  4. (Optional, Boolean) Indicates whether to ignore an unmapped
  5. type and not return any documents instead of an error
  6. false:文档标识不匹配,返回error
  7. true:文档表示不匹配,不返回error
  8. max_children:可选,最多含有满足条件的子文档数,超过该值不返回父文档
  9. min_children:可选,最少含有满足条件的子文档数,小于该值不返回父文档
  10. score_mode:可选,标识子文档得分如何影响父文档得分,可选值如下
  11. none (Default):无影响,父文档得分为0
  12. avg:所有匹配子文档的平均得分
  13. max:所有匹配子文档的最高得分
  14. min:所有匹配子文档的最低得分
  15. sum:所有匹配子文档得分和

                 

                  

********************

parent id query

父文档的id值为指定值,返回子文档

  1. # 索引:my-index-000001
  2. PUT /my-index-000001
  3. {
  4. "mappings": {
  5. "properties": {
  6. "my-join-field": {
  7. "type": "join",
  8. "relations": {
  9. "my-parent": "my-child"
  10. }
  11. }
  12. }
  13. }
  14. }
  15. # 插入父文档
  16. PUT /my-index-000001/_doc/1?refresh
  17. {
  18. "text": "This is a parent document.",
  19. "my-join-field": "my-parent"
  20. }
  21. # 插入子文档
  22. PUT /my-index-000001/_doc/2?routing=1&refresh
  23. {
  24. "text": "This is a child document.",
  25. "my_join_field": {
  26. "name": "my-child",
  27. "parent": "1"
  28. }
  29. }
  30. # 查询条件:父文档的id=1
  31. GET /my-index-000001/_search
  32. {
  33. "query": {
  34. "parent_id": {
  35. "type": "my-child",
  36. "id": "1"
  37. }
  38. }
  39. }

               

相关参数

  1. type:必选,子文档标识
  2. id:必选,父文档 id
  3. ignore_unmapped:可选,truefalse(默认)
  4. (Optional, Boolean) Indicates whether to ignore an unmapped
  5. type and not return any documents instead of an error
  6. false:子文档表示不匹配,返回error
  7. true:子文档表示不匹配,不返回error

                

               

********************

children aggregation

            

字聚合:特殊的单桶聚合(a special single bucket aggregation),根据join 子标识字段聚合,

  1. # 新建索引:child_example
  2. PUT child_example
  3. {
  4. "mappings": {
  5. "properties": {
  6. "join": {
  7. "type": "join",
  8. "relations": {
  9. "question": "answer"
  10. }
  11. }
  12. }
  13. }
  14. }
  15. # 父文档
  16. PUT child_example/_doc/1
  17. {
  18. "join": {
  19. "name": "question"
  20. },
  21. "body": "<p>I have Windows 2003 server and i bought a new Windows 2008 server...",
  22. "title": "Whats the best way to file transfer my site from server to a newer one?",
  23. "tags": [
  24. "windows-server-2003",
  25. "windows-server-2008",
  26. "file-transfer"
  27. ]
  28. }
  29. # 子文档
  30. PUT child_example/_doc/2?routing=1
  31. {
  32. "join": {
  33. "name": "answer",
  34. "parent": "1"
  35. },
  36. "owner": {
  37. "location": "Norfolk, United Kingdom",
  38. "display_name": "Sam",
  39. "id": 48
  40. },
  41. "body": "<p>Unfortunately you're pretty much limited to FTP...",
  42. "creation_date": "2009-05-04T13:45:37.030"
  43. }
  44. # 子文档
  45. PUT child_example/_doc/3?routing=1&refresh
  46. {
  47. "join": {
  48. "name": "answer",
  49. "parent": "1"
  50. },
  51. "owner": {
  52. "location": "Norfolk, United Kingdom",
  53. "display_name": "Troll",
  54. "id": 49
  55. },
  56. "body": "<p>Use Linux...",
  57. "creation_date": "2009-05-05T13:45:37.030"
  58. }

              

children aggregation

  1. POST child_example/_search?size=0
  2. {
  3. "aggs": {
  4. "top-tags": { # 父文档根据字段tags聚合
  5. "terms": {
  6. "field": "tags.keyword",
  7. "size": 10
  8. },
  9. "aggs": {
  10. "to-answers": {
  11. "children": { # children 聚合
  12. "type" : "answer"
  13. },
  14. "aggs": {
  15. "top-names": {
  16. "terms": { # 子文档根据owner.diaplay_name聚合
  17. "field": "owner.display_name.keyword",
  18. "size": 10
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }

             

聚合结果

  1. {
  2. "took": 25,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped" : 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total" : {
  12. "value": 3,
  13. "relation": "eq"
  14. },
  15. "max_score": null,
  16. "hits": []
  17. },
  18. "aggregations": {
  19. "top-tags": {
  20. "doc_count_error_upper_bound": 0,
  21. "sum_other_doc_count": 0,
  22. "buckets": [
  23. {
  24. "key": "file-transfer",
  25. "doc_count": 1,
  26. "to-answers": {
  27. "doc_count": 2,
  28. "top-names": {
  29. "doc_count_error_upper_bound": 0,
  30. "sum_other_doc_count": 0,
  31. "buckets": [
  32. {
  33. "key": "Sam",
  34. "doc_count": 1
  35. },
  36. {
  37. "key": "Troll",
  38. "doc_count": 1
  39. }
  40. ]
  41. }
  42. }
  43. },
  44. {
  45. "key": "windows-server-2003",
  46. "doc_count": 1,
  47. "to-answers": {
  48. "doc_count": 2,
  49. "top-names": {
  50. "doc_count_error_upper_bound": 0,
  51. "sum_other_doc_count": 0,
  52. "buckets": [
  53. {
  54. "key": "Sam",
  55. "doc_count": 1
  56. },
  57. {
  58. "key": "Troll",
  59. "doc_count": 1
  60. }
  61. ]
  62. }
  63. }
  64. },
  65. {
  66. "key": "windows-server-2008",
  67. "doc_count": 1,
  68. "to-answers": {
  69. "doc_count": 2,
  70. "top-names": {
  71. "doc_count_error_upper_bound": 0,
  72. "sum_other_doc_count": 0,
  73. "buckets": [
  74. {
  75. "key": "Sam",
  76. "doc_count": 1
  77. },
  78. {
  79. "key": "Troll",
  80. "doc_count": 1
  81. }
  82. ]
  83. }
  84. }
  85. }
  86. ]
  87. }
  88. }
  89. }

                 

                     

********************

示例

           

join ==> school:student

父文档:id、name、join(school)

子文档:id、name、sex、join(student)

                 

创建索引

  1. PUT school_student
  2. {
  3. "mappings": {
  4. "properties": {
  5. "join": {
  6. "type": "join",
  7. "relations": {
  8. "school": "student"
  9. }
  10. }
  11. }
  12. }
  13. }

                

插入父文档

  1. PUT school_student/_doc/1
  2. {
  3. "name":"火影忍者",
  4. "join": "school"
  5. }
  6. PUT school_student/_doc/2
  7. {
  8. "name":"海贼王",
  9. "join": "school"
  10. }

               

插入子文档:parent = 1

  1. # parent 1的子文档
  2. PUT school_student/_doc/3?routing=1
  3. {
  4. "name":"鸣人",
  5. "sex": "male",
  6. "join": {
  7. "name":"student",
  8. "parent": 1
  9. }
  10. }
  11. PUT school_student/_doc/4?routing=1
  12. {
  13. "name":"雏田",
  14. "sex": "female",
  15. "join": {
  16. "name":"student",
  17. "parent": 1
  18. }
  19. }
  20. PUT school_student/_doc/5?routing=1
  21. {
  22. "name":"小樱",
  23. "sex": "female",
  24. "join": {
  25. "name":"student",
  26. "parent": 1
  27. }
  28. }
  29. PUT school_student/_doc/6?routing=1
  30. {
  31. "name":"二柱子",
  32. "sex": "male",
  33. "join": {
  34. "name":"student",
  35. "parent": 1
  36. }
  37. }

                  

插入子文档:parent = 2

  1. PUT school_student/_doc/7?routing=2
  2. {
  3. "name":"路飞",
  4. "sex": "male",
  5. "join": {
  6. "name":"student",
  7. "parent": 2
  8. }
  9. }
  10. PUT school_student/_doc/8?routing=2
  11. {
  12. "name":"绿藻头",
  13. "sex": "male",
  14. "join": {
  15. "name":"student",
  16. "parent": 2
  17. }
  18. }
  19. PUT school_student/_doc/9?routing=2
  20. {
  21. "name":"色厨子",
  22. "sex": "male",
  23. "join": {
  24. "name":"student",
  25. "parent": 2
  26. }
  27. }
  28. PUT school_student/_doc/10?routing=2
  29. {
  30. "name":"撒谎布",
  31. "sex": "male",
  32. "join": {
  33. "name":"student",
  34. "parent": 2
  35. }
  36. }
  37. PUT school_student/_doc/11?routing=2
  38. {
  39. "name":"娜美",
  40. "sex": "female",
  41. "join": {
  42. "name":"student",
  43. "parent": 2
  44. }
  45. }
  46. PUT school_student/_doc/12?routing=2
  47. {
  48. "name":"罗宾",
  49. "sex": "female",
  50. "join": {
  51. "name":"student",
  52. "parent": 2
  53. }
  54. }

                   

                      

parent id query:parent id = 1的子文档

  1. # 查询语句
  2. GET school_student/_search
  3. {
  4. "query": {
  5. "parent_id": {
  6. "type": "student",
  7. "id": "1"
  8. }
  9. }
  10. }
  11. # 查询结果:返回4条子文档
  12. {
  13. "took" : 1021,
  14. "timed_out" : false,
  15. "_shards" : {
  16. "total" : 1,
  17. "successful" : 1,
  18. "skipped" : 0,
  19. "failed" : 0
  20. },
  21. "hits" : {
  22. "total" : {
  23. "value" : 4,
  24. "relation" : "eq"
  25. },
  26. "max_score" : 0.6325226,
  27. "hits" : [
  28. {
  29. "_index" : "school_student",
  30. "_type" : "_doc",
  31. "_id" : "3",
  32. "_score" : 0.6325226,
  33. "_routing" : "1",
  34. "_source" : {
  35. "name" : "鸣人",
  36. "sex" : "male",
  37. "join" : {
  38. "name" : "student",
  39. "parent" : 1
  40. }
  41. }
  42. },
  43. {
  44. "_index" : "school_student",
  45. "_type" : "_doc",
  46. "_id" : "4",
  47. "_score" : 0.6325226,
  48. "_routing" : "1",
  49. "_source" : {
  50. "name" : "雏田",
  51. "sex" : "female",
  52. "join" : {
  53. "name" : "student",
  54. "parent" : 1
  55. }
  56. }
  57. },
  58. {
  59. "_index" : "school_student",
  60. "_type" : "_doc",
  61. "_id" : "5",
  62. "_score" : 0.6325226,
  63. "_routing" : "1",
  64. "_source" : {
  65. "name" : "小樱",
  66. "sex" : "female",
  67. "join" : {
  68. "name" : "student",
  69. "parent" : 1
  70. }
  71. }
  72. },
  73. {
  74. "_index" : "school_student",
  75. "_type" : "_doc",
  76. "_id" : "6",
  77. "_score" : 0.6325226,
  78. "_routing" : "1",
  79. "_source" : {
  80. "name" : "二柱子",
  81. "sex" : "male",
  82. "join" : {
  83. "name" : "student",
  84. "parent" : 1
  85. }
  86. }
  87. }
  88. ]
  89. }
  90. }

                   

has child query:查询包含子文档name = 罗宾的父文档

  1. # 查询语句
  2. GET school_student/_search
  3. {
  4. "query": {
  5. "has_child": {
  6. "type": "student",
  7. "query": {
  8. "match": {
  9. "name": "罗宾"
  10. }
  11. }
  12. }
  13. }
  14. }
  15. # 查询结果
  16. {
  17. "took" : 4,
  18. "timed_out" : false,
  19. "_shards" : {
  20. "total" : 1,
  21. "successful" : 1,
  22. "skipped" : 0,
  23. "failed" : 0
  24. },
  25. "hits" : {
  26. "total" : {
  27. "value" : 1,
  28. "relation" : "eq"
  29. },
  30. "max_score" : 1.0,
  31. "hits" : [
  32. {
  33. "_index" : "school_student",
  34. "_type" : "_doc",
  35. "_id" : "2",
  36. "_score" : 1.0,
  37. "_source" : {
  38. "name" : "海贼王",
  39. "join" : "school"
  40. }
  41. }
  42. ]
  43. }
  44. }

                    

has parent query:查询父文档name = 海贼王的子文档

  1. # 查询语句
  2. GET school_student/_search
  3. {
  4. "query": {
  5. "has_parent": {
  6. "parent_type": "school",
  7. "query": {
  8. "match": {
  9. "name": "海贼王"
  10. }
  11. }
  12. }
  13. }
  14. }
  15. # 查询结果
  16. {
  17. "took" : 7,
  18. "timed_out" : false,
  19. "_shards" : {
  20. "total" : 1,
  21. "successful" : 1,
  22. "skipped" : 0,
  23. "failed" : 0
  24. },
  25. "hits" : {
  26. "total" : {
  27. "value" : 6,
  28. "relation" : "eq"
  29. },
  30. "max_score" : 1.0,
  31. "hits" : [
  32. {
  33. "_index" : "school_student",
  34. "_type" : "_doc",
  35. "_id" : "7",
  36. "_score" : 1.0,
  37. "_routing" : "2",
  38. "_source" : {
  39. "name" : "路飞",
  40. "sex" : "male",
  41. "join" : {
  42. "name" : "student",
  43. "parent" : 2
  44. }
  45. }
  46. },
  47. {
  48. "_index" : "school_student",
  49. "_type" : "_doc",
  50. "_id" : "8",
  51. "_score" : 1.0,
  52. "_routing" : "2",
  53. "_source" : {
  54. "name" : "绿藻头",
  55. "sex" : "male",
  56. "join" : {
  57. "name" : "student",
  58. "parent" : 2
  59. }
  60. }
  61. },
  62. {
  63. "_index" : "school_student",
  64. "_type" : "_doc",
  65. "_id" : "9",
  66. "_score" : 1.0,
  67. "_routing" : "2",
  68. "_source" : {
  69. "name" : "色厨子",
  70. "sex" : "male",
  71. "join" : {
  72. "name" : "student",
  73. "parent" : 2
  74. }
  75. }
  76. },
  77. {
  78. "_index" : "school_student",
  79. "_type" : "_doc",
  80. "_id" : "10",
  81. "_score" : 1.0,
  82. "_routing" : "2",
  83. "_source" : {
  84. "name" : "撒谎布",
  85. "sex" : "male",
  86. "join" : {
  87. "name" : "student",
  88. "parent" : 2
  89. }
  90. }
  91. },
  92. {
  93. "_index" : "school_student",
  94. "_type" : "_doc",
  95. "_id" : "11",
  96. "_score" : 1.0,
  97. "_routing" : "2",
  98. "_source" : {
  99. "name" : "娜美",
  100. "sex" : "female",
  101. "join" : {
  102. "name" : "student",
  103. "parent" : 2
  104. }
  105. }
  106. },
  107. {
  108. "_index" : "school_student",
  109. "_type" : "_doc",
  110. "_id" : "12",
  111. "_score" : 1.0,
  112. "_routing" : "2",
  113. "_source" : {
  114. "name" : "罗宾",
  115. "sex" : "female",
  116. "join" : {
  117. "name" : "student",
  118. "parent" : 2
  119. }
  120. }
  121. }
  122. ]
  123. }
  124. }

                  

chidren query:查询不同school下的男女人数

  1. # 查询语句
  2. GET school_student/_search
  3. {
  4. "query": {
  5. "terms": {
  6. "name.keyword": ["火影忍者","海贼王"]
  7. }
  8. },
  9. "aggs": {
  10. "school_count": {
  11. "terms": {
  12. "field": "name.keyword",
  13. "size": 10
  14. },
  15. "aggs": {
  16. "student_count": {
  17. "children": {
  18. "type": "student"
  19. },
  20. "aggs": {
  21. "sex_count": {
  22. "terms": {
  23. "field": "sex.keyword",
  24. "size": 10
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31. }
  32. }
  33. # 查询结果
  34. {
  35. "took" : 11,
  36. "timed_out" : false,
  37. "_shards" : {
  38. "total" : 1,
  39. "successful" : 1,
  40. "skipped" : 0,
  41. "failed" : 0
  42. },
  43. "hits" : {
  44. "total" : {
  45. "value" : 2,
  46. "relation" : "eq"
  47. },
  48. "max_score" : 1.0,
  49. "hits" : [
  50. {
  51. "_index" : "school_student",
  52. "_type" : "_doc",
  53. "_id" : "1",
  54. "_score" : 1.0,
  55. "_source" : {
  56. "name" : "火影忍者",
  57. "join" : "school"
  58. }
  59. },
  60. {
  61. "_index" : "school_student",
  62. "_type" : "_doc",
  63. "_id" : "2",
  64. "_score" : 1.0,
  65. "_source" : {
  66. "name" : "海贼王",
  67. "join" : "school"
  68. }
  69. }
  70. ]
  71. },
  72. "aggregations" : {
  73. "school_count" : {
  74. "doc_count_error_upper_bound" : 0,
  75. "sum_other_doc_count" : 0,
  76. "buckets" : [
  77. {
  78. "key" : "海贼王",
  79. "doc_count" : 1,
  80. "student_count" : {
  81. "doc_count" : 6,
  82. "sex_count" : {
  83. "doc_count_error_upper_bound" : 0,
  84. "sum_other_doc_count" : 0,
  85. "buckets" : [
  86. {
  87. "key" : "male",
  88. "doc_count" : 4
  89. },
  90. {
  91. "key" : "female",
  92. "doc_count" : 2
  93. }
  94. ]
  95. }
  96. }
  97. },
  98. {
  99. "key" : "火影忍者",
  100. "doc_count" : 1,
  101. "student_count" : {
  102. "doc_count" : 4,
  103. "sex_count" : {
  104. "doc_count_error_upper_bound" : 0,
  105. "sum_other_doc_count" : 0,
  106. "buckets" : [
  107. {
  108. "key" : "female",
  109. "doc_count" : 2
  110. },
  111. {
  112. "key" : "male",
  113. "doc_count" : 2
  114. }
  115. ]
  116. }
  117. }
  118. }
  119. ]
  120. }
  121. }
  122. }

                 

             

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/456687
推荐阅读
相关标签
  

闽ICP备14008679号