title: Put attributes in nested objects or in fields in the root (faceted aggregation)
body: <p><strong>TLDR :</strong> 
  <a href="https://stackoverflow.com">This use case</a> uses <code>name</code> / <code>value</code> inside a nested object for faceted filters and aggregations.</p>
  
  <p>1- Why is it better than a simple field:value in the root of the document without nested field ?</p>
  
  <p>2- Can you give me a use case that a simple field:value can't handle ?</p>
  
  <p>3- Why is this so complicated to do a faceted aggregation in this <a href="https://stackoverflow.com/questions/41369749/elasticsearch-generic-facets-structure-calculating-aggregations-combined-wit">stackoverflow question</a> ? What am I missing ?</p>
  
  <p>Remark : I know the key value inside nested architecture allows to have a really limited number of fields (the limit by default is 1000 on elasticsearch), but it's not a concern in my case because I know I am going to have a limited number of fields. Is there an other benefit than that ?</p>
  
  <p><strong>Details</strong></p>
  
  <p>Let's try and make a faceted aggregation on an index with only field: value at the root.
  This is the car index : </p>
  
  <pre><code>PUT /car
  {
  
  "settings": {
      "analysis": {
        "normalizer": {
          "govz_normalizer": {
            "type": "custom",
            "filter": [
              "lowercase",
              "asciifolding"
            ]
          }
        }
      }
    },    
    "mappings": {
      "dynamic_templates": [
          {
            "simple_string": {
              "mapping": {
                "type": "keyword",
                "normalizer": "govz_normalizer"
              },
              "path_match": "simple_string_*"
            }
          },
          {
            "simple_number": {
              "mapping": {
                "type": "double"
              },
              "path_match": "simple_number_*"
            }
          }
        ]
    }
  }
  
  </code></pre>
  
  <p>This is the seed :</p>
  
  <pre><code>POST car/_doc
  {"name": "car_name_1", "simple_string_brand": "Toyota", "simple_string_property": "luxury" }
  POST car/_doc
  {"name": "car_name_2", "simple_string_brand": "Ford","simple_string_property": "luxury"  }
  POST car/_doc
  {"name": "car_name_3", "simple_string_brand": "Toyota", "simple_string_property": "sportive"  }
  POST car/_doc
  {"name": "car_name_4", "simple_string_brand": "Honda", "simple_string_property": "city"  }
  POST car/_doc
  {"name": "car_name_5", "simple_string_brand": "Toyota", "simple_string_property": "luxury" }
  
  </code></pre>
  
  <p>We can see that faceted aggregations work perfectly</p>
  
  <pre><code>GET car/_search
  {
      "query": {
          "bool": {
              "should": [
                  {
                      "match_all": {}
                  }
              ],
              "filter": {
                  "bool": {
                      "must": [
                          {
                              "term": {
                                  "simple_string_property": "luxury"
                              }
                          },
                          {
                              "term": {
                                  "simple_string_brand": "toyota"
                              }
                          }
                      ]
                  }
              }
          }
      },
      "aggs": {
          "brand": {
              "terms": {
                  "field": "simple_string_brand"
              }
          },
          "property": {
              "terms": {
                  "field": "simple_string_property"
              }
          }
      }
  }
  </code></pre>
  
  <p>Result : </p>
  
  <pre><code>{
      "took": 13,
      "timed_out": false,
      "_shards": {
          "total": 5,
          "successful": 5,
          "skipped": 0,
          "failed": 0
      },
      "hits": {
          "total": {
              "value": 2,
              "relation": "eq"
          },
          "max_score": 1.0,
          "hits": [
              {
                  "_index": "car",
                  "_type": "_doc",
                  "_id": "75",
                  "_score": 1.0,
                  "_source": {
                      "name": "car_name_1",
                      "simple_string_brand": "Toyota",
                      "simple_string_property": "luxury"
                  }
              },
              {
                  "_index": "car",
                  "_type": "_doc",
                  "_id": "33278",
                  "_score": 1.0,
                  "_source": {
                      "name": "car_name_5",
                      "simple_string_brand": "Toyota",
                      "simple_string_property": "luxury"
                  }
              }
          ]
      },
      "aggregations": {
          "property": {
              "doc_count_error_upper_bound": 0,
              "sum_other_doc_count": 0,
              "buckets": [
                  {
                      "key": "luxury",
                      "doc_count": 2
                  }
              ]
          },
          "brand": {
              "doc_count_error_upper_bound": 0,
              "sum_other_doc_count": 0,
              "buckets": [
                  {
                      "key": "toyota",
                      "doc_count": 2
                  }
              ]
          }
      }
  }
  </code></pre>