当我在弹性搜索中执行任何搜索查询时,我会自动添加这些字段的输出
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 17,
"successful": 17,
"failed": 0
},
"hits": {
"total": 122,
"max_score": 10.268,
"hits": [
{
"_index": "imdb",
"_type": "txt",
"_id": "f4c8929735ad",
"_score": 11.775636,
我想要的字段是_source
"_source": {
"actor_name": {
"attribute": "value2"
},
"age_data":{
"perm": 29
}
}
如何过滤掉弹出搜索中除_source
以外的输出显示的所有内容?
答案 0 :(得分:1)
您可以使用过滤器路径功能仅过滤您想要的内容。这样的事情应该会有所帮助:
host:port/_search?pretty&filter_path=hits.hits._source
在这种情况下,你会得到这样的回应:
{
"hits": {
"hits": [
{
"_source": {
"type": "type",
"date": "2018-05-10T16:54:54.162Z"
}
},
{
"_source": {
"type": "type",
"date": "2018-05-14T10:39:15.903Z"
}
}
]
}
}
有关过滤器路径的更多信息 - https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering