0

I'm using the elasticsearch javascript library and am struggling to figure out how to just return whats inside of the _source object...I pull that data like this:

  client.search({
    index: 'kafkajmx2',
    body: {
          "_source": "*",
          "size": 10000,
          "query": {
            "bool": {
              "must": [
                { "match": { "metric_name": "IsrExpandsPerSec.Count" }}
                ],
              "filter": [
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-60m"
                    }
                  }
                }
                ]
            }
          }

        }
  })

but I don't get just the source back...if I change "_source": "*" to "_source": true, I still get the same results back...

lightweight
  • 3,227
  • 14
  • 79
  • 142
  • 1
    basically you cant. you can either pase the JSON to get what's inside `_source` or use an intermediate service to do it so that you send request to your intermediate service and get only `_source` in your javascript. – Ali Hashemi Feb 15 '17 at 04:42

1 Answers1

0

There is metadata that is associated with the results that are returned. The * that you are indicating in the _source is only used for the fields within _source, and not the meta data, which is everything outside the _source object in your JSON payload. Elasticsearch - how to return only data, not meta information? I believe is similar to what you are asking, and it appears that it is not doable, although that question is fairly old as there are newer versions of ElastiSearch out there. Looking at the latest version, as of this writing is 5.2, does not allow you to do this. You will need to parse the returned results from the query.

Community
  • 1
  • 1
PTaladay
  • 49
  • 10