I have the following ElasticSearch query, which, I think, will return all matches in the email field , where it is equal to myemails@email.com
"query": {
"bool": {
"must": [
{
"match": {
"email": "myemail@gmail.com"
}
}
]
}
}
The mapping for the type of user that is being searched is as follows:
{
"users": {
"mappings": {
"user": {
"properties": {
"email": {
"type": "string"
},
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"nickname": {
"type": "string"
},
}
}
}
}
}
Below is an example of the results obtained from ElasticSearch
[{
"_index": "users",
"_type": "user",
"_id": "54b19c417dcc4fe40d728e2c",
"_score": 0.23983537,
"_source": {
"email": "johnsmith@gmail.com",
"name": "John Smith",
"nickname": "jsmith",
},
{
"_index": "users",
"_type": "user",
"_id": "9c417dcc4fe40d728e2c54b1",
"_score": 0.23983537,
"_source": {
"email": "myemail@gmail.com",
"name": "Walter White",
"nickname": "wwhite",
},
{
"_index": "users",
"_type": "user",
"_id": "4fe40d728e2c54b19c417dcc",
"_score": 0.23983537,
"_source": {
"email": "JimmyFallon@gmail.com",
"name": "Jimmy Fallon",
"nickname": "jfallon",
}]
From the above query, I would think that the value of the email property should be an exact match with ' myemail@gmail.com '.
How the ElasticSearch DSL query should be executed in order to return only exact matches in the email .