Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch: ignore_malformed not working

I tried to put ignore_malformed for the property of a field in ElasticSearch Mapping.

EClient.indices.putMapping(
  {
    index: 'activities',
    type: 'user',
    body: {
      properties: {
        meta: {
          type: 'object',
          ignore_malformed: true, // meta is dynamic
        },
      },
    },
  },
  (err, res) => {
    console.info('Put Mapping Error:', err);
    console.info('Put Mapping Res:', res);
  }
);

But I get

response: '{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [meta] has unsupported parameters:  [ignore_malformed : true]"}],"type":"mapper_parsing_exception","reason":"Mapping definition for [meta] has unsupported parameters:  [ignore_malformed : true]"},"status":400}'

According to the documentation: ignore_malformed it should work. Is there someone who can tell me what is wrong with my codes?

like image 664
Colin Wang Avatar asked Aug 17 '17 07:08

Colin Wang


2 Answers

The documentation written isn't accurate as discussed here. I tried experimenting with ignore_malformed parameter and found that it doesn't work with strings and object type, though it works with integer as expected. You can probably raise a ticket for elasticsearch or use the workaround discussed in this link.

like image 97
Jai Sharma Avatar answered Oct 23 '22 07:10

Jai Sharma


try enabled: false instead of ignore_malformed for objects. This makes sure that this field can have an arbitrary inner structure (however it is not searchable then)

like image 41
alr Avatar answered Oct 23 '22 06:10

alr