2
{
   "query":{
      "bool":{
         "must":{
            "match_all":{

            }
         },
         "filter":[
            {
               "script":{
                  "source":"doc['id'].value == doc['_id'].value",
                  "lang":"painless"
               }
            }
         ]
      }
   },
   "track_total_hits":true
}

So doc['_id'].value is the line that causing error. How should i compare field value with _id value?

In normal documents "_id" is string and "id" is long, but i broke a few and now in them both are strings, how could I find them?

1 Answers1

1

I think your id field type is keyword, so; you can't call doc['id'].value without .keyword.

try this:

"script": {
    "script": {
        "source": "doc['id.keyword'].value == doc['_id'].value",
        "lang": "painless"
    }
}
Nimer Awad
  • 3,967
  • 3
  • 17
  • 31