大小不适用于Elasticsearch中的复合聚合

时间:2019-11-09 00:55:14

标签: elasticsearch elasticsearch-aggregation elasticsearch-7

我有以下查询:

GET index_name/_search
{
  "size": 0, 
  "aggs": {
    "my_buckets": {
      "composite": {
        "size": 100,
        "sources": [
          {
            "field1": {
              "terms": {
                "field": "field1"
              }
            }
          },
          {
            "field2": {
              "terms": {
                "field": "field2.raw"
              }
            }
          },
         {
            "field3": {
              "terms": {
                "field": "field3"
              }
            }
          },
          {
            "field4": {
              "terms": {
                "field": "field4.raw"
              }
            }
          },
          ...
          {
            "field7": {
              "terms": {
                "field": "field7"
              }
            }
          }
        ]
      },
      "aggregations": {
        "hits": {
          "top_hits": { 
            "size": 100, 
            "_source": {
              "includes": "field10"
            }
          }
        }
      }
    }
  }
}

但是,结果只有8个存储桶和一个后键。我认为在key说完之后,我们会有更多结果。在那种情况下,为什么不在同一请求中检索到它? size不指定我希望从聚合结果中获得的存储桶数吗?

以下是我的回复:

{
  ...
  "hits" : {
   ...
  },
  "aggregations" : {
    "my_buckets" : {
      "after_key" : {
        "field1" : 0.0,
        "field2" : "0.0",
        "field3" : some-value,
        "field4" : "0.0",
        "field5" : "some-value",
        "field6" : "0.0",
        "field7" : 0
      },
      "buckets" : [
        {
          "key" : {
            "field1" : 0.0,
            "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
               ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                ...
              ]
            }
          }
        },
        {
          "key" : {
            "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 1,
          "hits" : {
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [
                {
                  ...
                }
              ]
            }
          }
        },
        {
          "field1" : 0.0,
             "field2" : "0.0",
            "field3" : some-value,
            "field4" : "0.0",
            "field5" : "some-value",
            "field6" : "0.0",
            "field7" : 0
          },
          "doc_count" : 2,
          "hits" : {
            "hits" : {
              "total" : 2,
              "max_score" : 1.0,
              "hits" : [
                {
                  ...
                },
                {
                 ...
                }
              ]
            }
          }
        }
      ]
    }
  }
}

我在这里想念什么?

0 个答案:

没有答案