Find empty strings in elasticsearch

前端 未结 6 1296
盖世英雄少女心
盖世英雄少女心 2021-01-18 14:58

I\'m trying to _search documents that has some specific value in the field.

{
  \"query\": {
      \"bool\": {
        \"must\": [
         {\"f         


        
6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 15:27

    You can try this temporary solution which works but isn't optimal - https://github.com/elastic/elasticsearch/issues/7515

    PUT t/t/1
    {
    "textContent": ""
    }
    
    PUT t/t/2
    {
     "textContent": "foo"
    }
    
    GET t/t/_search
    {
     "query": {
      "bool": {
       "must": [
        {
          "exists": {
            "field": "textContent"
          }
        }
      ],
      "must_not": [
        {
          "wildcard": {
            "textContent": "*"
          }
         }
       ]
      }
     }
    }
    

提交回复
热议问题