janks
janks

Reputation: 1

Query to match content of two fields in Kibana

I'm using ElasticSearch with Kibana for visualization. I want to build a query to match two different fields when they have the same content.
For example:

field1: address = google.com
field2: hostname = google.com

Is ist possible to match two fields without knowing their values?

Thanks!

Upvotes: 0

Views: 2848

Answers (1)

Nishant
Nishant

Reputation: 7854

You can do this using painless script. The query will look as below:

{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": {
            "source": "doc['address'].value == doc['hostname'].value",
            "lang": "painless"
          }
        }
      }
    }
  }
}

To use in kibana you can create scripted field.

Upvotes: 1

Related Questions