Hi@all
i have many companies and each company has many products. But how i get the count of all products.
Query:
  GET /company/_search
    {
      "from": 0,
      "size": 5,
      "_source": false,
      "query": {
        "nested": {
          "path": "products",
          "inner_hits": {
            "_source": false
          },
          "query": {
            "match": {
              "products.category.id": 3
            }
          }
        }
      },
      "aggs": {
        "products": {
          "nested": {
            "path": "products"
          },
          "aggs": {
            "count": {
              "value_count": {
                "field": "products.id"
              }
            }
          }
        }
      }
    }
The result looks like:
  "aggregations": {
    "products": {
      "doc_count": 121,
      "count": {
        "value": 121
      }
    }
  }
This value is wrong. Me need Elasticsearch to tell, count please from inner_hits. But how?
Anybody a idea?