0

So I finally have an Elasticsearch index with some data in. If I perform the following query:

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

I receive the following output:

{
 "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"""
          }
        }
      }
    ]
  }
}

So my question is, How do I match against the content, but only return the raw content line (i.e. the path and filename) only?

bilpor
  • 3,467
  • 6
  • 32
  • 77
  • 1
    This answer should help: https://stackoverflow.com/questions/33481977/elasticsearch-remove-default-fields-from-searchs-response-body/33482067#33482067 (hint: use `filter_path`) – Val Aug 07 '17 at 07:33

1 Answers1

0

Val pointed me to the answer and I would have given him the Answer tick had it been an answer as opposed to a comment. My final answer in full to return what I want is:

`GET myindex/_search?q='perky'&filter_path=hits.hits._source.path.real`
bilpor
  • 3,467
  • 6
  • 32
  • 77