欢迎投稿

今日深度:

elasticsearch 处理null值,elasticsearchnull

elasticsearch 处理null值,elasticsearchnull


1.查询为空的字段

我们查询某个字段为空的数据时,在mysql中:
select eid,ent_name from ent_search where enttype_code is NULL;
在elasticsearch中,我们使用的api为exists,这个查询是:查询这个字段为空的或者没有这个字段的:
GET ent_search/_search
{
  "_source": ["eid","ent_name"], 
    "query": {
        "bool": {
            "must_not": {
                "exists": {
                    "field": "enttype_code"
                }
            }
        }
    }
}

2.查询某个不为空的字段

我们查询某个字段不为空的数据时,在mysql中:
select eid,ent_name from ent_search where enttype_code is NOT NULL;
在elasticsearch中,我们使用的api为exists,这个查询是:
GET ent_search/_search
{
  "_source": ["eid","ent_name","enttype_code"], 
  "query": {
    "constant_score": {
      "filter": {
        "exists": {
          "field": "enttype_code"
        }
      }
    }
  }
}

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/35533.html NewsArticle elasticsearch 处理null值,elasticsearchnull 1.查询为空的字段 我们查询某个字段为空的数据时,在mysql中: select eid,ent_name from ent_search where enttype_code is NULL ; 在elasticsearch中,我们使用的api为...
相关文章
    暂无相关文章
评论暂时关闭