Yes, this is possible by using a match query for your title query and a
nested query that wraps a match query for the deal names. Both the nested
and match query need to combined with a bool query. Example:
curl -XGET 'localhost:9200/_search' -d '
"query" : {
"bool" : {
"must" : [
{
"match" : {
"name" : {
"abc"
}
}
},
"nested" : {
"path" : "deals",
"query" : {
"match" : {
"name" : {
"best"
}
}
}
}
]
}
}
'
ES doesn't know that. I misread your question / example. The book.title
part should also be put into a nested query:
curl -XGET 'localhost:9200/_search' -d '
"query" : {
"bool" : {
"must" : [
{
"nested" : {
"path" : "books",
"query" : {
"match" : {
"books.title" : {
"abc"
}
}
}
}
},
"nested" : {
"path" : "deals",
"query" : {
"match" : {
"deals.name" : {
"best"
}
}
}
}
]
}
}
'
Also the field names inside the nested query should be the full path. The
above query should return any root document (author in your case) that has
a nested inner deal object with a name that has the term best and a
nested inner book object with title that has a term abc. Does this makes
sense?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.