title: Significant terms aggregation for arrays in elasticsearch
body: <p>I am unable to perform a significant terms aggregation using a field that is an array. My Javascript query looks like this:</p>
  
  <pre><code>client.search({
    index: myIndex,
    body: {
      query: {
        terms: {
          myField: ['someuserid']
          // also tried with same result... myField: 'someuserid'
        }
      },
      aggregations: {
        recommendations: {
          significant_terms: {
            field: "myField",
            min_doc_count: 1
          }
        }
      }
    }
  })
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>(node:13105) UnhandledPromiseRejectionWarning: Unhandled promise rejection 
  (rejection id: 1): Error: [illegal_argument_exception] Fielddata is disabled 
  on text fields by default. Set fielddata=true on [myField] in order to 
  load fielddata in memory by uninverting the inverted index. Note that this can 
  however use significant memory.
  </code></pre>
  
  <p>My mapping looks like this:</p>
  
  <pre><code>{
    index: 'myIndex',
    type: 'users',
    body: {
      properties: {
          'myField': []
      }
    }
  }
  </code></pre>
  
  <p>I know that I don't need to explicitly map array data types, but I do it so I can easily see what fields I have for a certain <code>type</code>. Following the error message I would change my mapping to look like this:</p>
  
  <pre><code>...
  properties: {
    myField: {
      fielddata: "true"
    }
  }
  ...
  </code></pre>
  
  <p>However, this results in this error:</p>
  
  <pre><code>Error: [mapper_parsing_exception] No type specified for field [myField]
  </code></pre>
  
  <p>If I were to then add a type:
      ...
      properties: {
        myField: {
          type: [],
          fielddata: "true"
        }
      }
      ...
  I would get this error:</p>
  
  <pre><code>[mapper_parsing_exception] No handler for type [[]] declared on field [myField]
  </code></pre>
  
  <p>Currently, the data I am aggregating is from data that is seeded through the Javascript client library completely using the Update API constructed with this:</p>
  
  <pre><code>const update = {
      "upsert": {
        "myField": ['myValue']
      },
      "script": {
      "inline": "ctx._source.myField.add(params.itemField)",
      "params": {
        "itemField": 'itemValue'
      }
    }
  };
  
  const req = {
      index: 'myIndex',
      type: 'users',
      id: 'someuserid',
      body: update
  }
  </code></pre>
  
  <p>Hits from this query <code>curl -XGET 'localhost:9200/myIndex/users/_search?pretty'</code> would then look like this:</p>
  
  <pre><code>...
  {
      "_index" : "myIndex",
      "_type" : "users",
      "_id" : "someuserid",
      "_score" : 1.0,
      "_source" : {
        "myField" : [
          "someFieldId1",
          "someFieldId1",
          "someFieldId2"
        ]
      }
    },
  ...
  </code></pre>
  
  <p>How can I properly perform a significant terms aggregation using a field that is an array?</p>