Need to store array data in Elasticsearch. The array can contain a string or object so I can accept both array types. I'm able to do this by defining individual array types. But I need a generic solution that accepts strings or objects in an array.
Object to store in Elasticsearch :
{
"anotherData": [
{
"someData": {
"testingName": [
{
"alternateName": "Another data",
"areaCategory": "some data"
}
]
}
}
]
}
Elasticsearch schema for storing above data :
{
....
"mappings": {
"properties": {
"testingName": {
"properties": {
"alternateName": {
"type": "keyword"
},
"areaCategory": {
"type": "keyword"
}
}
},
....
}
}
}
Another example of an object to store :
{
"anotherData": [
{
"someData": {
"testingName": [
"this is only a array string"
]
}
}
]
}
For the above object the Elasticsearch schema would be :
{
....
"mappings": {
"properties": {
"testingName": {
"type": "keyword"
},
....
}
}
}
I need to combine both in the schema as "any of one" condition. I can store any of the above two objects which could be an array of strings or an array of objects. Please share the Elasticsearch schema that can work for both types.