【发布时间】:2019-04-04 04:06:01
【问题描述】:
对我的弹性搜索数据库运行基本查询会给出不一致的结果。
我可以直接匹配通过ID查询的数据库
{
"query": {
"bool": {
"must": [
{
"term": {
"id": {
"value": "84e042ce-74e3-4c51-a1d9-db2f1c3d57ef"
}
}
}
]
}
}
}
这会按预期返回一条记录(显示 2 个字段)
"id": "84e042ce-74e3-4c51-a1d9-db2f1c3d57ef",
"usersNotified": "e721a8d9-8001-4003-9af9-1c7397fd7079,fc18bbc4-f7f1-4151-bf88-390597da9510,061c9195-cb97-4777-8577-a8e555b95c7f,8e4e7641-b135-46e5-b9b4-c42393450108,601785e7-1c18-43b4-924e-cf52a15e3204,ec132f25-3d1d-41d8-ab16-e60a53ee9483"
当我向查询中添加 match_phrase 以查找“usersNotified”字段中存在的 Guid 时,它返回为空。
{
"query": {
"bool": {
"must": [
{
"term": {
"id": {
"value": "84e042ce-74e3-4c51-a1d9-db2f1c3d57ef"
}
}
},
{
"match_phrase": {
"usersNotified": {
"query": "601785e7-1c18-43b4-924e-cf52a15e3204"
}
}
}
]
}
}
}
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
对不同记录的完全相同的查询(以及较短的 usersNotified 列表)确实成功返回了匹配项
{
"query": {
"bool": {
"must": [
{
"term": {
"id": {
"value": "d48e6ccc-f343-4840-af29-317fef829da1"
}
}
},
{
"match_phrase": {
"usersNotified": {
"query": "601785e7-1c18-43b4-924e-cf52a15e3204"
}
}
}
]
}
}
}
如图:
"id": "d48e6ccc-f343-4840-af29-317fef829da1",
"usersNotified": "e721a8d9-8001-4003-9af9-1c7397fd7079,fdc40427-9db0-44d8-8ce3-45c90489dc19,061c9195-cb97-4777-8577-a8e555b95c7f,601785e7-1c18-43b4-924e-cf52a15e3204,ec132f25-3d1d-41d8-ab16-e60a53ee9483"
所以我不明白为什么相同的查询在一种情况下有效,但在另一种情况下无效。任何帮助将不胜感激。
【问题讨论】:
-
能否提供样本数据?
-
我已经包含了上面的相关字段。 (“id”和“usersNotified”)在每个查询之后。不幸的是,我不能发布更多内容,因为它包含敏感信息
标签: elasticsearch