Arrays of objects

Arrays of objects do not work as you would expect: you cannot query each
object independently of the other objects in the array. If you need to be
able to do this then you should use the nested datatype instead
of the object datatype.

When adding a field dynamically, the first value in the array determines the
field type. All subsequent values must be of the same datatype or it must
at least be possible to coerce subsequent values to the same
datatype.

Arrays with a mixture of datatypes are not supported: [ 10, "some string" ]

An array may contain null values, which are either replaced by the
configured null_value or skipped entirely. An empty array
[] is treated as a missing field — a field with no values.

Nothing needs to be pre-configured in order to use arrays in documents, they
are supported out of the box:

The second document contains no arrays, but can be indexed into the same fields.

The query looks for elasticsearch in the tags field, and matches both documents.

Multi-value fields and the inverted index

The fact that all field types support multi-value fields out of the box is a
consequence of the origins of Lucene. Lucene was designed to be a full text
search engine. In order to be able to search for individual words within a
big block of text, Lucene tokenizes the text into individual terms, and
adds each term to the inverted index separately.

This means that even a simple text field must be able to support multiple
values by default. When other datatypes were added, such as numbers and
dates, they used the same data structure as strings, and so got multi-values
for free.