Hi, I'm trying to build a system that will have a user's phone book in nested field and this will have user_id and user_gender. I am trying to filter over gender in search result but i'm only getting the whole nested object in response of my query.
I'm wondering if there exists any mechanism that allows you to filter the array of nested objects and output specific fields
I'm using Elasticsearch 7.16
Below is the sample data for one user
"_source" : {
"user_id" : 1,
"user_gender" : 1,
"user_location" : {
"lat" : 33.765,
"lon" : 74.444
},
"phone_book" : [
{
"user_id" : 2,
"user_gender" : 1,
"user_location" : {
"lat" : 33.665,
"lon" : 74.444
}
},
{
"user_id" : 3,
"user_gender" : 0,
"user_location" : {
"lat" : 33.755,
"lon" : 74.444
}
},
{
"user_id" : 4,
"user_gender" : 0,
"user_location" : {
"lat" : 33.755,
"lon" : 74.444
}
},
{
"user_id" : 5,
"user_gender" : 1,
"user_location" : {
"lat" : 33.755,
"lon" : 74.434
}
},
{
"user_id" : 6,
"user_gender" : 0,
"user_location" : {
"lat" : 33.655,
"lon" : 74.414
}
}
],
"user_relations" : {
"name" : "user"
}
}