gpt4 book ai didi

sql - Elasticsearch 等于 SQL %Like%

转载 作者:行者123 更新时间:2023-12-02 22:15:19 25 4
gpt4 key购买 nike

来自 here我向自己询问此类查询的 elasticsearch 语法:

WHERE text LIKE "%quick%"
AND text LIKE "%brown%"
AND text LIKE "%fox%"

我的尝试(不幸的是没有成功)
  "query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"terms": {
"text": [
"*quick*",
"*brown*",
"*fox*"
]
}
}
]
}
}
]
}
}

最佳答案

尝试使用 boolwildcard做这样的查询。

{
"query": {
"bool": {
"must": [
{
"wildcard": {
"text": "*quick*"
}
},
{
"wildcard": {
"text": "*brown*"
}
},
{
"wildcard": {
"text": "*fox*"
}
}
]
}
}
}

Wildcard Query Matches documents that have fields matching a wildcard expression (not analyzed). Supported wildcards are *, which matches any character sequence (including the empty one), and ?, which matches any single character.

关于sql - Elasticsearch 等于 SQL %Like%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47437931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com