I am new to elasticsearch. I have nested data.Users->Cars. I need help in writing nested mappings.
I have seen ES site regarding nesting query and basic one I am able to do. I ran into trouble while creating mapping for lets say depth 2/3.
The following mapping I am trying to create but it does not seem to be working.
I need to be able to query something like:
get me all the documents where users.usertype=salaried
and cars.make=honda
.
Here is my mapping:
{
"mappings": {
"properties": {
"users": {
"type": "nested",
"usertype": {
"type": "text"
},
"cars": {
"type": "nested",
"properties": {
"make": {
"type": "text"
},
"model": {
"type": "text"
}
}
}
}
}
}
}
Here is my sample data:
{
"users": [
{
"usertype": "salaried",
"cars": [
{
"make": "honda"
},
{
"year": "2016"
}
]
},
{
"usertype": "business",
"cars": [
{
"make": "BMW"
},
{
"year": "2018"
}
]
}
]
}
While creating mapping I am getting following error:
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [user] has unsupported parameters: [details : {type=nested, properties={make={type=text}}}]"
}