title: Get count of particular field in a document using Elasticsearch
body: <p>Requirement:
  I want to find the count of aID for a particular category ID.
  (i.e for categoryID 2532 i want the count as 2 that means it is assigned to two aID's).</p>
  
  <p>I tried with aggregations but with that i can able to get only the doc count rather than field count.</p>
  
  <p>Mappings</p>
  
  <pre><code> "List": {
              "properties": {
  
                "aId": {
                  "type": "long"
                },
                "CategoryList": {
                  "properties": {                  
                    "categoryId": {
                      "type": "long"
                    },
                    "categoryName": {
                      "type": "string"
                    }
                  }
                }              
              }
            }
  </code></pre>
  
  <p>Sample Document:</p>
  
  <pre><code>"List": [
              {
                "aId": 33074,           
                "CategoryList": [
                  {
                    "categoryId": 2532,
                    "categoryName": "VODAFONE"                
                  }
                ]
              },
          {
                "aId": 12074,           
                "CategoryList": [
                  {
                    "categoryId": 2532,
                    "categoryName": "VODAFONE"                
                  }
                ]
              },
  
          {
                "aId": 120755,           
                "CategoryList": [
                  {
                    "categoryId": 1234,
                    "categoryName": "SMPLKE"                
                  }
                ]
              }
            ]
  </code></pre>