Hi
I have my index defined as
"person": {
"firstName": { "type": "string"},
"lastName": { "type": "string" },
"email": {
"type": "nested",
"properties": {
"address": {"type": "string" }
This is like one person can have zero to many email address.
I would like to write a query which will do a prefix match of either first name, last name, or email, and should have at least one email address for the matching person first name or last name.
I know how to apply exist query condition, but not able to apply filter with should clause on first name or last name...
{
"query" : {
"nested" : {
"path" : "email",
"query" : { "match_all" : { } },
"filter" : {
"exists" : { "field" : "email.address" }
}
}
}
}
eg:
-
firstName: "jack" lastName: "John" with no email should bring zero rows..when searchText is "jac"..even though this is matching firstname using prefix condition.
-
firstName: "andrew", lastName: "John" with an email: andrew.john@example.com
should bring the above row..when searchText is "and"
Using elasticsearch 2.3.4.. Appreciate any direction to this