How to Do a Mapping of Array of Strings in Elasticsearch

Micah picture Micah · Apr 20, 2017 · Viewed 35.6k times · Source

I can't find any examples of how to structure an array of strings in elasticsearch when trying to PUT a mapping to an index.

What I have for the field mapping:

:tags {:type :array :store true}

The error i get:

{:type "mapper_parsing_exception",
 :reason "No handler for type [array] declared on field [tags]"}

Answer

pippobaudos picture pippobaudos · Apr 21, 2017

In Elasticsearch, there is no dedicated array type. Any field can contain zero or more values by default, however, all values in the array must be of the same datatype.

So you don't have to specify anything specific in the mapping to store an array of values.

For more information look at: https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html