Elasticsearch如何仅返回“真实”路径

时间:2017-08-07 07:31:00

标签: elasticsearch

所以我最终得到了一个带有一些数据的Elasticsearch索引。如果我执行以下查询:

GET myindex/_search
{ "query" : {
  "match" : {"content": "perky"}
}

我收到以下输出:

{
 "took": 1,
 "timed_out": false,
 "_shards": {
 "total": 3,
 "successful": 3,
 "failed": 0
},
  "hits": {
  "total": 1,
  "max_score": 1.641338,
  "hits": [
    {
      "_index": "myindex",
      "_type": "doc",
      "_id": "b9c08da824e715ec1219d72d66904ce0",
      "_score": 1.641338,
      "_source": {
        "content": "pinky perky dave\n",
        "meta": {
          "raw": {
            "X-Parsed-By": "org.apache.tika.parser.DefaultParser",
            "Content-Encoding": "ISO-8859-1",
            "Content-Type": "text/plain; charset=ISO-8859-1"
          }
        },
        "file": {
          "extension": "txt",
          "content_type": "text/plain; charset=ISO-8859-1",
          "last_modified": "2017-08-04T14:57:03.593+0000",
          "indexing_date": "2017-08-04T14:57:25.795+0000",
          "filesize": 16,
          "filename": "testsub.txt",
          "url": """file://w:\Elasticsearch\Docs\DocsSub\testsub.txt"""
        },
        "path": {
          "root": "f8297de277471c98cd8d97615cb13e9f",
          "virtual": "/DocsSub/testsub.txt",
          "real": """w:\Elasticsearch\Docs\DocsSub\testsub.txt"""
          }
        }
      }
    ]
  }
}

所以我的问题是,我如何匹配内容,但只返回raw内容行(即路径和文件名)?

1 个答案:

答案 0 :(得分:0)

瓦尔向我指出了答案,我会给他答案,如果答案是答案而不是评论。我的最终答案是完全回复我想要的:

`GET myindex/_search?q='perky'&filter_path=hits.hits._source.path.real`