1

I'm new to elasticsearch. I'm re-indexing old index to new index. but while re-indexing millions of records sometime, I am getting mapper_parsing_exception exception. so my question is that, Is there a way to set ignore_malformed flag true of an already existing index.

Naresh Singh
  • 167
  • 4
  • 9
  • When reindexing, you should always explicitly set the mapping of the target index before launching the reindex, because the reindex doesn't do it for you. – Val Nov 30 '20 at 06:11
  • yeah, I understand that.. but our old index has dynamic mapping and our new index has static mapping. but I think in dynamic mapping by default ignore_malformed flag is true. so now when re-indexing we are getting mapping_parser_exception. is there way to avoid it. – Naresh Singh Nov 30 '20 at 06:42
  • You can set `ignore_malformed` [at the index level](https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html#ignore-malformed-setting) before kicking off the reindexing – Val Nov 30 '20 at 07:24
  • but it is possible to set ignore_malformed flag true of already exist index. – Naresh Singh Nov 30 '20 at 09:19

1 Answers1

2

Yes, it's possible to change the ignore_malformed setting dynamically simply by running this:

PUT logstash_june_2019/doc/_mapping
{
  "properties": {
    "createdAt": {
      "type" : "date",
      "ignore_malformed": true             <--- add this
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360
  • I tried your solution... but elasticsearch throwing exception: resource_already_exists_exception – Naresh Singh Dec 01 '20 at 05:16
  • Can you show what you executed exactly? And which version of ES are you using? – Val Dec 01 '20 at 05:16
  • 1
    ES verison: 6.4.2 PUT logstash_june_2019/_mapping { "properties": { "createdA": { "type" : "long", "ignore_malformed": true } } } – Naresh Singh Dec 01 '20 at 06:03
  • What do you get when running `GET logstash_june_2019`? – Val Dec 01 '20 at 06:15
  • all the mapped field of index logstash_june_2019 – Naresh Singh Dec 01 '20 at 06:33
  • Yeah, I would like to see the response you get, please – Val Dec 01 '20 at 06:47
  • actully response is very big: "logstash_june_2019": { "aliases": {}, "mappings": { "doc": { "dynamic": "false", "_all": { "enabled": true }, "properties": { "appt_date_time": { "type": "long" }, "appt_id": { "type": "long" }, "createdAt": { "type": "date" – Naresh Singh Dec 01 '20 at 06:51
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/225355/discussion-between-naresh-singh-and-val). – Naresh Singh Dec 01 '20 at 10:15