将SQL查询转换为ElasticSearch查询



我用SQL编写了这个查询,现在我需要它在弹性搜索中。我该怎么做呢?

select * from listings where condition1 = true or (condition2 = 1 and condition3 = false)

给你:

POST listings/_search
{
"query": {
"bool": {
"should": [
{
"term": {
"condition1": {
"value": "true"
}
}
},
{
"bool": {
"must": [
{
"term": {
"condition2": {
"value": "1"
}
}
},
{
"term": {
"condition3": {
"value": "false"
}
}
}
]
}
}
]
}
}
}

or需要使用should子句,and需要使用must子句。

您需要根据您的需求使用termmatch查询。

最新更新