Hi,
I have a below sample piece of data,
"indCodes":{
"industryCodeTypes": [
{
"typeDBCode": 1016,
"typeDescription": "US SIC",
"industryCode": [
{
"code": 1099,
"description": "Metal mining-other metal ores",
"priority": 1
}
]
},
{
"typeDBCode": 19295,
"typeDescription": "SIC 2007",
"industryCode": [
{
"code": 70100,
"description": "Activities of head offices",
"priority": 1
},
{
"code": 7290,
"description": "Mining of other non-ferrous metal ores",
"priority": 2
},
{
"code": 7000,
"description": "Mining of metal ores",
"priority": 3
}
]
}
]
}
So for the above sample data I have prepared below mapping,
"indCodes":{
"properties": {
"industryCodeTypes": {
"type": "nested",
"properties": {
"industryCode": {
"type": "nested",
"properties": {
"code": {
"type": "long"
},
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"priority": {
"type": "long"
}
}
},
"typeDescription": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"typeDBCode": {
"type": "long"
}
}
}
}
}
is the above mapping correct as per my sample data, if yes then, i need below scenarios
if i give typeDBCode: 1016 and code: 1099 - I should get one record as output which is coming
if i give typeDBCode: 19295 and code: 1099 - I should not get records but still i am getting.
Below is my query,
{
"query":{
"bool":{
"must":[{
"nested": {
"path": "standardisedFinancials.identification.industryCodes.industryCodeTypes",
"query" : {
"bool" : {
"must" : [
{ "match" : {"standardisedFinancials.identification.industryCodes.industryCodeTypes.typeDnBCode" : "19295"} }
]
}
}
}
},
{
"nested": {
"path": "standardisedFinancials.identification.industryCodes.industryCodeTypes.industryCode",
"query" : {
"bool" : {
"must" : [
{ "terms" : {"standardisedFinancials.identification.industryCodes.industryCodeTypes.industryCode.code" : ["6111","1099"]} },
{ "match" : {"standardisedFinancials.identification.industryCodes.industryCodeTypes.industryCode.priority" : "1"} }
]
}
}
}
}]
}
}
}
Kindly let me know where i did mistake.
Thanks in advance.
Thanks & Regards,
Ram Prasad G