嘿~ 今天天气不错嘛

这样的sql 如何写dsl

Elasticsearch | 作者 zhangye | 发布于2021年03月15日 | 阅读数:989

SELECT
*
FROM
test_produce
WHERE
(publish_platform = 1
AND (
play_count IS NULL
OR digg_count IS NULL
OR share_count IS NULL
OR comment_count IS NULL
)) or
(publish_platform = 3
AND (
play_count IS NULL
OR digg_count IS NULL
OR share_count IS NULL
OR comment_count IS NULL
))
;
已邀请:

thewind

赞同来自: zhangye zhangdi

GET test_produce/_search
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"publish_platform": {
"value": 1
}
}
},
{
"bool": {
"should": [
{
"bool": {
"must_not": [
{
"exists": {
"field": "play_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "digg_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "share_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "comment_count"
}
}
]
}
}
]
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"publish_platform": {
"value": 3
}
}
},
{
"bool": {
"should": [
{
"bool": {
"must_not": [
{
"exists": {
"field": "play_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "digg_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "share_count"
}
}
]
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "comment_count"
}
}
]
}
}
]
}
}
]
}
}
]
}
}
}

要回复问题请先登录注册