Timestamp dayOfWeek

Hi, I'm trying to create a visualization in kibana by filtering on the timestamp field. I want to filter by day of the week.

For the moment, I obtain the sum for a given month, but I would like to remove specific days from this sum (for example, count every Mondays). I tried by making a scripted fields or directly by putting a DSL and/or KQL query, but without success.

Here is an example of the filter I am trying to do in DSL Query. However, the script returns me zero results:

{
  "query": {
    "bool": {
      "must": {
        "script": {
          "script": {
            "source": "doc['@timestamp'].value.dayOfWeek == 1",
            "lang": "painless"
          }
        }
      }
    }
  }
}

Do you have any ideas on how to make this type of filter?

Thx

Hi @Alexandre_CHERAMY,

Below query worked for me:

{
  "query": {
    "script": {
      "script": {
        "source": "doc['@timestamp'].value.getDayOfWeek().getValue() == 1",
        "lang": "painless"
      }
    }
  }
}