I have the below JSON documents in elastic search.
Document 1
{
"name":"abc",
"class": "First"
"marks": [
{"subject": "science", "total": 100},
{"subject": "maths", "total": 100}
]
}
Document 2
{
"name":"cde",
"class": "First"
"marks": [
{"subject": "science", "total": 100},
{"subject": "maths", "total": 100}
]
}
When I query for class 1, I need to get the results like below.
[
{
"name":"abc",
"class": "First",
"subject": "science",
"total": 100
},
{
"name":"abc",
"class": "First",
"subject": "maths",
"total": 100
},
{
"name":"cde",
"class": "First",
"subject": "science",
"total": 100
},
{
"name":"cde",
"class": "First",
"subject": "maths",
"total": 100
}
]
Is this possible to get the results in this format or close to this format in elastic search? Do we need nested types to achieve this? I am trying to avoid processing the result and creating the flat structure in the code. Elastic search version is 7.9
question from:
https://stackoverflow.com/questions/65617292/elastic-search-unwind-an-array-attribute-in-a-document 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…