es有办法仅返回_source里的内容吗?去掉_index、_type等外围字段!

{
    "_index": "test",
    "_type": "test",
    "_id": "2802",
    "_score": 1.0,
    "_source": {
        "NAME": "diye"
    }
}

有什么方法可以返回数据时,只要_source里的内容。外围的_index, xxx, _source都不要!

可以使用参数来指定只返回某一部分的内容,例如"?filter_path=hits.hits._source,hits.total"指定返回hits元素下的hits数组以及total元素,且其中hits数组的元素中只包含_source元素,不包含_index、_score等数据

你之前的问题解决了吗?

首先 使用
datas = data_search["hits"]["hits"]返回es列表
然后使用
datas[0]["_source"]
返回列表中第一条数据的_sourse内容,也就是去掉外围字段的内容