如何在 elasticsearch 中用户查询 should 和 must_not

how to user query should and must_not in elasticseacrh

我有像这样的弹性数据

{
  "xId" : "25b35718-1804-428e-87fc-e215422d21a0",
  "date" : "2019-10-13T07:07:07.558Z",
  "type" : "promo",
  "accountId" : 50,
  "readBy" : [
    "b",
    "a"
  ]
}

我想在多个条件下检索数据 ,所以我使用 should 和 must_not 进行查询,当我使用该查询时,数组 returns 为空,但现在数据仍然出现,是否缺少某些内容?

这是我的示例查询

{"query": {
          "constant_score": {
            "filter": {
              "bool": {
                "should": [
                  {
                    "terms": {
                      "accountId": [50]
                    }
                  },{
                    "terms": {
                      "type": ["promo"]
                    }
                  },
                  {
                    "match": {
                      "userId": "a"
                    }
                  }
                ],
                "must_not": [
                  {
                    "terms": {
                      "type": []
                    }
                  }, {
                    "terms": {
                      "readBy": ["a"]
                    }
                  }

                ]
              }
            }
          }
        }
      }

已解决 我使用这样的查询

{"query": {
      "constant_score": {
        "filter": {
          "bool": {
            "should": [
              {
                "terms": {
                  "accountId": [50]
                }
              },{
                "terms": {
                  "type": ["promo"]
                }
              },
              {
                "match": {
                  "userId": "a"
                }
              }
            ],
            "must_not": [
              {
                "terms": {
                  "type": []
                }
              }, {
                "term": {
                  "readBy.keyword": "a"
                }
              }

            ]
          }
        }
      }
    }
  }