我用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
子句。
您需要根据您的需求使用term
或match
查询。