How to Do a Mapping of Array of Strings in Elasticsearch

52,606

Solution 1

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

Solution 2

Just write

:tags { "type" : "text" }

It works for store array in Elasticsearch.

Share:
52,606
Micah
Author by

Micah

CTO @ gooten.com

Updated on May 28, 2021

Comments

  • Micah
    Micah almost 3 years

    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]"}