# \_update\_by\_query "lenient" flag not recognized

**URL:** <https://discuss.elastic.co/t/update-by-query-lenient-flag-not-recognized/265639>\
**Category:** Elasticsearch\
**Created:** [February 26, 2021, 5:03pm UTC](https://discuss.elastic.co/t/update-by-query-lenient-flag-not-recognized/265639 "2021-02-26T17:03:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan3/32/77517_2.png) [@dan3](https://discuss.elastic.co/u/dan3)\
**Post date:** [February 26, 2021, 5:03pm UTC](https://discuss.elastic.co/t/update-by-query-lenient-flag-not-recognized/265639/1 "2021-02-26T17:03:13Z")

</div>

I'm having an issue with updating an index via \_update\_by\_query. I have certain fields that are causing format errors so I'm trying to skip them using the "lenient" flag outlined in the documentation. I'm using elasticsearch 7.10.

Query:

```auto
    POST /dummy-index/_update_by_query?lenient=true
    {
      "query": { 
        "term": {
          "user.id": "kimchy"
        }
      }
    }

```

Result:

```auto
    {
      "error" : {
        "root_cause" : [
          {
            "type" : "illegal_argument_exception",
            "reason" : "request [/dummy-index/_update_by_query] contains unrecognized parameter: [lenient]"
          }
        ],
        "type" : "illegal_argument_exception",
        "reason" : "request [/dummy-index/_update_by_query] contains unrecognized parameter: [lenient]"
      },
      "status" : 400
    }

```

To give a bit more context this is the error I face when I run the update query:

```auto
          "cause" : {
            "type" : "mapper_parsing_exception",
            "reason" : "failed to parse field [@timestamp] of type [date] in document with id 'lZCFKncBPKE3DmYvI5D0'. Preview of field's value: '1.590399287522615E9'",
            "caused_by" : {
              "type" : "illegal_argument_exception",
              "reason" : "failed to parse date field [1.590399287522615E9] with format [epoch_second||date_time]",
              "caused_by" : {
                "type" : "date_time_parse_exception",
                "reason" : "Failed to parse with all enclosed parsers"
              }
            }
          }

```

caused by some old documents that had a misconfigured timestamp field. Incidentally this doesn't seem to cause any issues when doing a re-index operation against the same index template.

Am I able to somehow skip the errors and only update the documents with valid timestamps? Alterantively, can I filter out the offending documents and remove them from the index?

Appreciate any help!

---

<div class="post-metadata">

**Author:** ![dan3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan3/32/77517_2.png) [@dan3](https://discuss.elastic.co/u/dan3)\
**Post date:** [March 1, 2021, 3:30pm UTC](https://discuss.elastic.co/t/update-by-query-lenient-flag-not-recognized/265639/2 "2021-03-01T15:30:36Z")

</div>

I managed to get it working for my use case. Since certain timestamps were stored as a double I had to convert them during the update. Something like:

```auto
if(ctx._source['@timestamp'] instanceof double){
    ctx._source['@timestamp'] = new Date( ( (long) ctx._source['@timestamp'] ) * 1000);
}

```

I still think that there is some sort of bug with Elastic not recognizing the "lenient" flag and I'm not sure why reindexing doesn't cause these errors.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 29, 2021, 3:30pm UTC](https://discuss.elastic.co/t/update-by-query-lenient-flag-not-recognized/265639/3 "2021-03-29T15:30:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
