39

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

2 Answers 2

50

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

Sign up to request clarification or add additional context in comments.

2 Comments

what if i want to specify analyzer for array elements?
@Rajeev you specify an analyser as if the elements were not in an array. That analyser is applied to each item. They are not analysed as a whole array or group.
3

Just write

:tags { "type" : "text" }

It works for store array in Elasticsearch.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.