Get only selected fields in Anomaly detection jobs API

Hi, I want to retrieve only the value of "job_id" when I make this query

GET _ml/anomaly_detectors/

It is posible to use something like "_source " in the _search queries to only retrieve the "job_id"?

That is an API call, not a query to an index. The rough equivalent to querying the index to only return job names would be something like:

GET .ml-config/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "job_type": "anomaly_detector"
          }
        }
      ]
    }
  },
  "_source": "job_id"
}
1 Like

If you want to make the API call then something like this might work for you:

curl localhost:9200/_ml/anomaly_detectors/?pretty | awk -F" : " '/job_id/{print $2}' | sed 's/\",//g' | sed 's/\"//g'

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.