weixin_43501485
2019-03-07 21:18 阅读 2.3k

es 查询怎么排除那些只要有一条数据是空的字段

es 查询怎么排除那些只要有一条数据是空的字段
比如我es中的数据是这样的:

{
  "took": 28,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 1,
    "hits": [
      {
        "_index": "shop",
        "_type": "book",
        "_id": "AWlTdeg9-uKcfYQht2cG",
        "_score": 1,
        "_source": {
          "id": 10006573,
          "name": "Elasticsearch action",
          "author": "Radu Gheorghe",
          "num": 120,
          "content": "这本实战型的书籍聚焦在使用HTTP协议的Elasticsearch REST API代码片段的书写多数是使用cURL的bash脚本,所以很容易翻译成其他编程语言。",
          "price": 39.5,
          "published": "2018-10-01"
        }
      },
      {
        "_index": "shop",
        "_type": "book",
        "_id": "AWlTkwr8-uKcfYQht2cH",
        "_score": 1,
        "_source": {
          "id": 20004812,
          "name": "Spring action",
          "author": "Radu go",
          "num": 120,
          "content": "这是一本简要简介spring d的书籍。",
          "price": 39.5
        }
      },
      {
        "_index": "shop",
        "_type": "book",
        "_id": "AWlTlIUH-uKcfYQht2cI",
        "_score": 1,
        "_source": {
          "id": 20004812,
          "name": "elasticsearch action",
          "author": "john"
        }
      }
    ]
  }
}

我要查询出来每条数据都不为空的字段,正确的结果应该是:
{
"id": 20004812,
"name": "elasticsearch action",
"author": "john"
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐