GET index1/doc/_search
{
  "query": {
    "bool": {
      "must": {
        "terms": {
          "title": [
            "日本","核泄漏"
          ]
        }
      },
      "filter": {
        "range": {
          "publish_at": {
            "gte": "2021-04-13T00:00:00.000Z"
          }
        }
      }
    }
  },
  "sort": {
    "publish_at": {
      "order": "desc"
    }
  },
  "size": 10
}
{
  "query": {
    "bool": {
      "should": [
        {
          "terms": {
            "title": [
              "中国"
            ]
          }
        },
        {
          "terms": {
            "content": [
              "中国"
            ]
          }
        }
      ],
      "must_not": [
        {
          "terms": {
            "title": [
              "美国",
              "日本"
            ]
          }
        },
        {
          "terms": {
            "content": [
              "美国",
              "日本"
            ]
          }
        }
      ],
      "filter": {
        "range": {
          "publish_at": {
            "gte": "2021-01-01T00:00:00.000Z"
          }
        }
      },
      "minimum_should_match":1
    }
  },
  "sort": {
    "publish_at": {
      "order": "desc"
    }
  },
  "size": 10
}

参考

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐