Aggregating over _field_names in elasticsearch 5
<p>I'm trying to aggregate over field names in ES 5 as described in <a href="https://stackoverflow.com/questions/39228585/elasticsearch-aggregation-on-distinct-keys">Elasticsearch aggregation on distinct keys</a> But the solution described there is not working anymore.</p>

<p>My goal is to get the keys across all the documents. Mapping is the default one.</p>

<p>Data:</p>

<pre><code>PUT products/product/1
{
    "param": {
        "field1": "data",
        "field2": "data2"
    }   
}
</code></pre>

<p>Query:</p>

<pre><code>GET _search
{
    "aggs": {
        "params": {
            "terms": {
                "field": "_field_names",
                "include" : "param.*",   
                "size": 0
            }

        }
    }
}
</code></pre>

<p>I get following error: <code>Fielddata is not supported on field [_field_names] of type [_field_names]</code></p>