gpt4 book ai didi

spring-boot - 即时通讯无法将我的mysql查询转换为elasticsearch查询

转载 作者:行者123 更新时间:2023-12-03 01:36:59 24 4
gpt4 key购买 nike

我是Elasticsearch的初学者。我最近将我的搜索数据库从MySQL更改为Elasticsearch,但是我无法转换其中一个查询。查询如下。

select * from table 
where (col1 = "a" and col2 = "b")
or (col1 = "c" and col2 = "d")
and col3 = "z";

最佳答案

所有关于必须和应该一起过滤以执行此类查询的内容。

以下查询是您的SQL语句的elasticsearch查询。

GET _search
{
"query": {
"bool": {
"must": [
{
"term": {
"col3": {
"value": "z"
}
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"col1": {
"value": "a"
}
}
},
{
"term": {
"col2": {
"value": "b"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"col1": {
"value": "c"
}
}
},
{
"term": {
"col2": {
"value": "d"
}
}
}
]
}
}
]
}
}
]
}
}
}

关于spring-boot - 即时通讯无法将我的mysql查询转换为elasticsearch查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51700183/

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