Mapping
PUT /employee
{
"mappings": {
"post": {
"properties": {
"name": {
"type": "keyword"
},
"email_ids": {
"properties":{
"id" : { "type" : "integer"},
"value" : { "type" : "keyword"}
}
},
"primary_email_id":{
"type": "integer"
}
}
}
}
}
Data
POST employee/post/1
{
"name": "John",
"email_ids": [
{
"id" : 1,
"value" : "[email protected]"
},
{
"id" : 2,
"value" : "[email protected]"
}
],
"primary_email_id": 2 // Here 2 refers to the id field of email_ids.id ([email protected]).
}
I need help to form a query to check if an email id is already taken as a primary email?
eg: If I query for [email protected] I should get result as No as [email protected] is not a primary email id.
If I query for [email protected] I should get result as Yes as [email protected] is a primary email id for John.