我有以下 ElasticSearch 查询,我认为它会在等于myemails@email.com的电子邮件字段上返回所有匹配项
"query": {
"bool": {
"must": [
{
"match": {
"email": "myemail@gmail.com"
}
}
]
}
}
正在搜索的用户类型的映射如下:
{
"users": {
"mappings": {
"user": {
"properties": {
"email": {
"type": "string"
},
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"nickname": {
"type": "string"
},
}
}
}
}
}
以下是 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",
}]
从上面的查询中,我认为这需要与 'myemail@gmail.com' 作为电子邮件属性值完全匹配。
ElasticSearch DSL 查询需要如何更改才能仅在电子邮件上返回完全匹配。