I've been a while playing with elastic search and(I think) I got a non-satisfied result from my queries. I would like to get all documents that must have four conditions puts inside but because an unknown reason I receive documents that accomplish 2-3 of 4 conditions.
I read on official documentation some about arrays that is not supported apply queries to objects independently from each other so i tried as nested property, I think this is a little bit confuse queries
Someone know a better approach to this situation?
Index object example
[
{
emails: [
{
accounts: [1,2,3,4],
address: "abc@abc.com"
}
],
interactions: [
{
account_id: 1,
type: "form",
created: "2019-10-23 10:25:48",
additional: {
action: "one",
id: 111
}
},
{
account_id: 1,
type: "form",
created: "2019-04-23 15:25:48",
additional: {
action: "one",
id: 222
}
}
]
},
{
emails: [
{
accounts: [3,4],
address: "def@def.com"
}
],
interactions: [
{
account_id: 1,
type: "form",
created: "2013-11-23 00:25:48",
additional: {
action: "two",
id: 111
}
},
{
account_id: 1,
type: "form",
created: "2016-07-03 04:25:48",
additional: {
action: "one",
id: 222
}
}
]
}
]
Query
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "interactions.interactable",
"query": {
"bool": {
"must": [
{ "term": { "interactions.additional.action.keyword": "two" } },
{ "term": { "interactions.additional.id": 111 } }
]
}
}
}
},
{
"nested": {
"path": "emails",
"query": {
"bool": {
"must": [
{ "term": { "emails.address.keyword": "def@def.com" } }
]
}
}
}
}
]
}
}
}
I'll hope you can guide me about this.
ElasticSearch & Kibana on 7.3.0 version.
Kind regards,