带有筛选项的Elasticsearch布尔查询和返回不一致结果的字符串搜索



我正在对Elasticsearch运行以下查询,该查询基于字符串搜索和属性项匹配来匹配文档。当我通过一个学期时,我会得到预期的结果,但当我再加上第二个学期,我不会得到同样的结果。想法?

{
"_source": {
"includes": [
"docID"
]
},
"query": {
"bool": {
"must": [
{
"terms": {
"userID": [
1,
2,
71
]
}
},
{
"query_string": {
"query": "**test**",
"fields": [
"attachment.content"
]
}
}
]
}
}
}

如果我只传递userID 1,忽略其他的,我会得到我期望的docID(即1,4,8(,但当我传递所有三个userID时,结果中缺少几个docID(例如1、6、8,但没有4(。使用Elasticsearch 6.5。

希望有人比我更明白为什么会这样!

提前感谢!

默认情况下,ES返回结果为10。也许丢失的文件在下一页。我们可以将大小增加到更大的数字,例如:

{
"size": 30, // put size here
"_source": {
"includes": [
"docID"
]
},
"query": {
"bool": {
"must": [
{
"terms": {
"userID": [
1,
2,
71
]
}
},
{
"query_string": {
"query": "**test**",
"fields": [
"attachment.content"
]
}
}
]
}
}
}

最新更新