【发布时间】:2014-07-21 00:23:48
【问题描述】:
如果只是点击 api,每个文档中有 5 个字段。但我只想要这两个字段(user_id 和 loc_code),所以我在字段列表中提到。但它仍然返回一些不必要的数据,如_shards、hits、time_out 等。
使用以下查询在 chrome 中的邮递员插件中发出 POST 请求
<:9200>/myindex/mytype/_search
{
"fields" : ["user_id", "loc_code"],
"query":{"term":{"group_id":"1sd323s"}}
}
// 输出
{
"took": 17,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 323,
"max_score": 8.402096,
"hits": [
{
"_index": "myindex",
"_type": "mytype",
"_id": "<someid>",
"_score": 8.402096,
"fields": {
"user_id": [
"<someuserid>"
],
"loc_code": [
768
]
}
},
...
]
}
}
但我只想要文档字段(两个提到的字段),我也不想要 _id、_index、_type。有什么办法吗
【问题讨论】:
标签: elasticsearch full-text-search