Search code examples
elasticsearchsearchjaeger

Search in Jaeger ElasticSearch


My query from the Jaeger ElasticSearc returns the following entry

    "_index" : "jaeger-span-2020-07-31",
    "_type" : "span",
    "_source" : {
      "startTime" : 1596157225275112,
      "startTimeMillis" : 1596157225275,
      "duration" : 0,
      "tags" : [
        {
          "key" : "span.kind",
          "type" : "string",
          "value" : "server"
        },
        {
          "key" : "internal.span.format",
          "type" : "string",
          "value" : "zipkin"
        }
      ],
      "process" : {
        "serviceName" : "transaction-manager",
      }
    }
  }

My goal is to find entries which have tag["internal.span"] "zipkin". Field "tags" is "nested". I am trying a query like the one below. I do not get hits. What do I miss?

{
  "from": 0,
  "size": 1,
  "query": { 
          "bool": {
              "must": [ 
                  {"match": { "process.serviceName": "transaction-manager" }},
                  {
                          "nested": {
                              "path": "tags",
                              "query": {
                                  "match": {
                                      "value": "zipkin"
                                  }
                              }
                          }
                  }
              ]
          }
      }
}

Solution

  • You just need to make use of tags.value instead of value in your match query.

    Below query should help:

    POST <your_index_name>/_search
    {
      "from": 0,
      "size": 1,
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "process.serviceName": "transaction-manager"
              }
            },
            {
              "nested": {
                "path": "tags",
                "query": {
                  "match": {
                    "tags.value": "zipkin"        <---- Note this
                  }
                }
              }
            }
          ]
        }
      }
    }