如何将列表作为查询字符串传递给match_phrase查询?
这样做是可行的:
{"match_phrase":{"requestParameters.bucketName":{“查询”:“xxx”}},
这并不意味着:
{
"match_phrase": {
"requestParameters.bucketName": {
"query": [
"auditloggingnew2232",
"config-bucket-123",
"web-servers",
"esbck-essnap-1djjegwy9fvyl",
"tempexpo",
]
}
}
}发布于 2021-01-06 18:39:00
match_phrase根本不支持多个值。
您可以使用should查询:
GET _search
{
"query": {
"bool": {
"should": [
{
"match_phrase": {
"requestParameters.bucketName": {
"value": "auditloggingnew2232"
}
}
},
{
"match_phrase": {
"requestParameters.bucketName": {
"value": "config-bucket-123"
}
}
}
]
},
...
}
}或者,正如@Val指出的,是一个terms查询:
{
"query": {
"terms": {
"requestParameters.bucketName": [
"auditloggingnew2232",
"config-bucket-123",
"web-servers",
"esbck-essnap-1djjegwy9fvyl",
"tempexpo"
]
}
}
}在确切的条件下,它的功能类似于OR。
我假设1)所讨论的桶名是唯一的,2)您不是在寻找部分匹配。如果是这样的话,如果在bucketName上几乎没有任何分析器,那么甚至不需要match_phrase!terms会做得很好。term和match_phrase查询之间的区别很好地解释了here。
https://stackoverflow.com/questions/63091114
复制相似问题