I have a contacts field in my documents in Elasticsearch. each element inside the contacts field is an Object itself. I want to use term or terms filter on contacts field so that it matches documents where contacts.province_id is X. I have tried contacts.province_id as search field but it doesn't work. How should I filter these kinds of fields?
"contacts":
[
{
"id": 1,
"address": "address1",
"tel": "40 07 13 22",
"doctor_id": 1,
"type_id": 1,
"lng": "51.374720",
"lat": "35.781986",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
},
{
"id": 2,
"address": "address2",
"tel": null,
"doctor_id": 1,
"type_id": 2,
"lng": "51.520313",
"lat": "35.726983",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
},
{
"id": 3,
"address": "address3",
"tel": null,
"doctor_id": 1,
"type_id": 2,
"lng": "51.456368",
"lat": "35.797505",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
}
]
EDIT :
I've tried this Query :
GET /index_name/type_name/_search
{
"query": {
"filtered": {
"filter": {
"term": {
"contacts.province_id": 8
}
}
}
}
}
but it returns 3 results, I expect 5 results. whats the problem?
Thanks for your help.