Размер не работает с композитными агрегатами в эластичном поиске - PullRequest
0 голосов
/ 09 ноября 2019

У меня следующий запрос:

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 сегментов и ключ после. Я предполагаю, что после того, как ключ говорит, что у нас есть больше результатов. В таком случае, почему он не получен в том же запросе? Разве размер не определяет количество сегментов, которые я ожидаю от результатов агрегации?

Ниже приведен мой ответ:

{
  ...
  "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" : [
                {
                  ...
                },
                {
                 ...
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Чего мне здесь не хватает?

...