0

I read on this article elasticsearch query and match query to be able to query for ElasticApmTraceId that has a specific ID throughout my entire logs.

enter image description here

So I attempted to do the following just to get ElasticApmTraceID:

GET /customer-simulation-es-app-logs*/_search
{
 "query": { 
   "match": {
     "fields": {
       "ElasticApmTraceId": "da58115e800c284b8e2556185c1c8e64"
     }
   }
 }
}

However, when I do so, it returns:

enter image description here

Is there a reason why it returns a 400 and not what I want it to do?

NoviceCoder
  • 449
  • 1
  • 9
  • 26

2 Answers2

1

Based on the structure of the document, the ElasticApmTraceId field is inside fields. You can access the values of ElasticApmTraceId by using fields.ElasticApmTraceId

Modify your query as

{
  "query": {
    "match": {
      "fields.ElasticApmTraceId": "da58115e800c284b8e2556185c1c8e64"
    }
  }
}
ESCoder
  • 15,431
  • 2
  • 19
  • 42
1

I suggest you use the bool,mustand term to query.The following article should help you: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

GET /customer-simulation-es-app-logs*/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "ElasticApmTraceId": {
              "value": "da58115e800c284b8e2556185c1c8e64"
            }
          }
        }
      ]
    }
  }
}
SuperPirate
  • 146
  • 1
  • 4