Can't map all fields to text type

I am trying to map all fields as text. Based on the docs, this should work, but it doesn't:

PUT my_type
{
  "mappings": {
    "my_type": {
      "dynamic_templates": [
        {
          "longs_as_strings": {
            "match_mapping_type": "*",
            "match":   "*",
            "mapping": {
              "type": "text"
            }
          }
        }
      ]
    }
  }
}

PUT my_type/my_type/1
{
  "intfield": 5
}

GET my_type/_search

Results in:

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "my_type",
        "_type": "my_type",
        "_id": "1",
        "_score": 1,
        "_source": {
          "intfield": 5
        }
      }
    ]
  }
}

Check what the mapping looks like by runniung GET /my_type/_mapping/my_type. Elasticsearch will not modify the source document, but that does not mean it is not correctly mapped.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.