Aggregation not working on query results

I have query like

{
  "size": 1,
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "must": [
              {
                "simple_query_string": {
                  "query": "sangeeth",
                  "default_operator": "OR"
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "match": {
                  "CreatedBy._id": "Us_78eb6dd0a46a11e8a1b10242ac12000b"
                }
              },
              {
                "match": {
                  "_created_by._id": "Us_78eb6dd0a46a11e8a1b10242ac12000b"
                }
              },
              {
                "match": {
                  "CurrentAssignedTo._id": "Us_78eb6dd0a46a11e8a1b10242ac12000b"
                }
              }
            ],
            "minimum_should_match": 1
          }
        }
      ]
    }
  },
  "aggregations": {
    "count_per_flows": {
      "terms": {
        "field": "_type"
      },
      "aggregations": {
        "Name": {
          "terms": {
            "field": "Flow.Name.keyword"
          }
        },
        "Id": {
          "terms": {
            "field": "Flow._id.keyword"
          }
        }
      }
    }
  }
}

I have mentioned size as 0 in my query. I got exact one document as result. But aggregation returns result with match of all documents.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.