一、概述

  有两种可行方案,如下:

  1. 使用exists过滤为null或无此字段的文档;使用精确查询过滤空字符串
  2. 使用wildcard通配符模糊查询

二、方案一:exists

GET /news/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "exists": {
            "field": "url"
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "url": ""
          }
        }
      ]
    }
  }
}

三、方案二:wildcard通配符(性能很差)

GET /news/_search
{
  "query": {
    "wildcard":{
      "text": {
        "value": "*"
      }
    }
  }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-05-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
猜你喜欢
  • 2022-02-05
  • 2019-01-22
  • 2022-12-23
  • 2022-01-25
  • 2021-06-29
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案