There is no datatype “Array” in elasticsearch. Let me explain the problem with examples:
Consider you have created this property below:
{
"tagIds": {
"type": "integer"
}
}
Then values are indexed with it:
{
"tagIds": [124, 452, 234]
}
Then tagIds automatically become an array of integers.
Now coming to your case. You have to create a field, such as “Name” with the type as a keyword. Also, always pass an array to this field even though if it has to store only one value, still make sure to keep it as an array. You need to do Mapping:
PUT test
{
"mappings": {
"_doc": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}
}
Indexing document:
PUT test/_doc/1
{
"name" : ["yuvi"]
}