可以通过指定elasticsearch中文档的字段,来指定返回文档中的字段:
通过_source
字段来指定需要返回的字段。
举例:根据关系单号,查询es,只需要返回salesType,policyNo,policyRelationNo,policyStatus
{
"_source": [
"salesType",
"policyNo",
"policyRelationNo",
"policyStatus"
],
"query": {
"bool": {
"must": [
{
"term": {
"policyRelationNo": "2201435021"
}
}
],
"should": [],
"must_not": []
}
},
"from": 0,
"size": 10
}
效果如下:
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 19,
"max_score": 11.391884,
"hits": [
{
"_index": "my_index",
"_type": "my_type"