完全 javascript elasticearch client.search-param与电子邮件完全匹配是什么?
我尝试了很多变体,但在我的测试数据上,只有一个文档,我总是得到该文档的匹配,即使是#34; aa@bb.cc& #34;
鉴于此映射:
curl -X GET 'http://localhost:9200/entity/user/_mapping?pretty'
"entity" : {
"mappings" : {
"user" : {
"properties" : {
"created_at" : {
"type" : "long"
},
"email" : {
"type" : "string",
"index" : "not_analyzed"
},
"login_token" : {
"properties" : {
"created_at" : {
"type" : "long"
},
"email" : {
"type" : "string"
},
"expires_at" : {
"type" : "long"
},
"merchant_id" : {
"type" : "string"
},
"token" : {
"type" : "string"
}
}
}
}
}
}
}
}
文件:
curl -X GET 'http://localhost:9200/entity/user/_search?pretty'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "entity",
"_type" : "user",
"_id" : "VzUs-y7QRUCUqr3SBuB-FQ",
"_score" : 1.0,
"_source":{"email":"gnimmelf@gmail.com"}
} ]
}
}
更新:尝试了@ progrrammer的建议:
user_email = "asafs@asfasf.afasfa"
res = yield client.search({
index: index,
type: type,
query : {
term: {
email: user_email
}
}
})
仍然给出了同样的血腥结果:
-> POST http://localhost:9200/entity/user/_search?query=
<- 200
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "entity",
"_type": "user",
"_id": "JUieGEOAQxeU2pc7HMieeQ",
"_score": 1,
"_source": {
"email": "gnimmelf@gmail.com",
...
更新2:这有效
res = yield client.search({
index: index,
type: type,
q: 'email='+user_email
})
所以官方的js客户端不知何故被淹没了。男人我厌倦了Elasticsearch ......
答案 0 :(得分:0)