Hi This is the mapping used-
"mappings": {
"doc" : {
"dynamic": "strict",
"properties": {
"nameId": {
"type": "text",
"fields": {
"keyword" : {
"type": "keyword"
}
}},
"a": {
"type": "nested",
"properties": {
"aType": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"aAmount": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
},
"integer":{
"type": "integer"
}
}
},
"aDefault": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"b": {
"type": "nested",
"properties": {
"bExpireDate": {
"type": "date",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"bAmount": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
},
"integer":{
"type": "integer"
}
}
},
"bCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"bBUID": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
}
}},
"c": {
"type": "nested",
"properties": {
"cExpireDate": {
"type": "date",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"cAmount": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
},
"integer":{
"type": "integer"
}
}
},
"cCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
},
"cBUID": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"null_value": "null"
}
}
}
}
}
}
}
}}}
}
This is the query used-
GET abc-demo/_search
{
"_source": false,
"query": {
"bool": {
"must": [
{
"nested": {
"path": "a",
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field":
"a.aDefault",
"query": "No*"
}
},
{
"query_string": {
"fields": [
"a.aAmount"
],
"query": ""
}
},{
"query_string": {
"default_field":
"a.aType",
"query": ""
}
} ]
}
},
"inner_hits": {
"size": 1,
"_source": {
"includes": [
"a.aAmount",
"a.aType",
"a.aDefault"
]
}
}
}
},
{ "bool": {
"should": [
{
"nested": {
"path": "a.b",
"query": {
"match": {
"a.b.bCode": "BPET"
}
},
"inner_hits": {
"size": 1,
"_source": {
"includes": [
"a.b.bCode"
]
}
}}
},
{
"nested": {
"path": "a.c",
"query": {
"match": {
"a.c.cCode": ""
}
},
"inner_hits": {
"size": 1,
"_source": {
"includes": [
"a.c.cCode"]
}} }} ] }} ]}}}