【发布时间】:2015-03-09 19:38:22
【问题描述】:
我有以下 ElasticSearch 查询,我认为它会返回 email 字段上的所有匹配项,它等于 myemails@email.com
"query": {
"bool": {
"must": [
{
"match": {
"email": "myemail@gmail.com"
}
}
]
}
}
正在搜索的 user 类型的映射如下:
{
"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 查询需要如何更改才能仅返回电子邮件上的完全匹配。
【问题讨论】:
标签: node.js elasticsearch elasticsearch-plugin