I've loaded the data provided here into elastic search.
Now I'm trying to query for Accounts.
- Age Must be 38.
- State Should not be "ID".
-
Address Should Contain Either: (This is not Working)
- The text "lane" OR
- The a complete text "mill avenue"
Request : POST - http://localhost:9200/bank/account/_search?pretty
{
"query": {
"bool": {
"should": [
{ "match": { "address": "lane" } },
{ "match_phrase": { "address": "mill avenue" } }
],
"must": [
{ "match": { "age": "38" } }
],
"must_not": [
{ "match": { "state": "ID" } }
]
}
},
"from": 0,
"size": 1,
"_source": ["account_number", "balance", "firstname", "lastname", "age", "email", "address", "state"],
"sort": [
{ "account_number": "asc" },
{ "balance": "desc"}
]
}
Response :
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 36,
"max_score": null,
"hits": [
{
"_index": "bank",
"_type": "account",
"_id": "21",
"_score": null,
"_source": {
"account_number": 21,
"firstname": "Estella",
"address": "859 Portal Street",
"balance": 7004,
"state": "WV",
"age": 38,
"email": "estellapaul@zillatide.com",
"lastname": "Paul"
},
"sort": [
21,
7004
]
}
]
}
}
You can check the response. The record with address "859 Portal Street" was received and it doesn't contain "lane" or "mill avenue".
Elastic Search Version : 5.1.1