One - One Code All

Blog Content

查询elasticsearch查询结果包含或排除某些字段

ElasticSearch   2016-11-23 17:21:42

通过_source字段中的include和exclude来指定返回结果包含哪些字段,排除哪些字段。


举例:根据关系单号,查询es,设置_source的include和exclude:

{
  "_source":{
    "include":[
      "policyNo",
      "policyRelationNo",
      "policyStatus"
    ],
    "exclude":[
       "salesType"
    ]
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "policyRelationNo": "KR01435021"
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  },
  "from": 0,
  "size": 10
}



上一篇:ElasticSearch亿级数据毫秒查询实现
下一篇:elasticsearch多个索引的数据的联合查询

The minute you think of giving up, think of the reason why you held on so long.