Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 从输出中隐藏超时、\u碎片、最大分数和其他默认字段_Json_Api_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Json,Api,elasticsearch" /> elasticsearch,Json,Api,elasticsearch" />

Json 从输出中隐藏超时、\u碎片、最大分数和其他默认字段

Json 从输出中隐藏超时、\u碎片、最大分数和其他默认字段,json,api,elasticsearch,Json,Api,elasticsearch,当我在弹性搜索中执行任何搜索查询时,我会得到自动添加这些字段的输出 { "took": 3, "timed_out": false, "_shards": { "total": 17, "successful": 17, "failed": 0 }, "hits": { "total": 122, "max_score": 10.268, "hits": [

当我在弹性搜索中执行任何搜索查询时,我会得到自动添加这些字段的输出

{
    "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,
我想要的字段是源代码下的所有内容


如何从输出中过滤掉除elasticsearch中的_source之外的所有内容?

您可以使用过滤路径功能仅过滤您想要的内容。类似这样的事情应该会有所帮助:

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"
        }
      }
    ]
  }
}
有关筛选器路径的详细信息-

{
  "hits": {
    "hits": [
      {
        "_source": {
          "type": "type",
          "date": "2018-05-10T16:54:54.162Z"
        }
      },
      {
        "_source": {
          "type": "type",
          "date": "2018-05-14T10:39:15.903Z"
        }
      }
    ]
  }
}