Home > Blockchain >  Count times items do not exist in an index
Count times items do not exist in an index

Time:04-07

I'm attempting to count the number of timers the field l.ts1 or l.ts2 does not exist :

Here is the query :

GET /data/_count
{
  "query": {
    "bool": {
        "must_not": {
          "exists": {
            { "term" : { "field":"l.ts1" },
            { "term" : { "field":"l.ts2" }
          }
        }
      }
  }
}

But returns error:

  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Failed to parse",
        "line" : 6,
        "col" : 21
      }
    ],

How to count the number of times two fields do not exist in an index ?

CodePudding user response:

There is an error in your query. Try this one:

GET /data/_count
{
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "l.ts1"
          }
        },
        {
          "exists": {
            "field": "l.ts2"
          }
        }
      ]
    }
  }
}
  • Related