0

I need help while trying to add ignore_malformed to my index settings.

I have:

from elasticsearch import Elasticsearch
es = Elasticsearch(
  [{'host': 'localhost', 'port': 9200}])

index_name = 'product'

settings = {
"settings": {
    "index.refresh_interval" : "1s",
    "index.mapping.total_fields.limit": 10000,
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
"mappings": {
  "properties": {
        "location": {
          "type": "geo_point"
        }
      },
    "dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    ]
  }
}

es.indices.create(index=index_name, body=settings)

If I try to add "index.mapping.ignore_malformed": true, I get: NameError: name 'true' is not defined

With following I can perform this setting but I need both at once while indexing:

from elasticsearch import Elasticsearch
# conntect es
es = Elasticsearch(
  [{'host': 'localhost', 'port': 9200}])
from elasticsearch_dsl import Index
index_name = 'product'
index = Index(index_name, es)
index.settings(
        index={'mapping':{'ignore_malformed':True}}
    )
index.create()

Under Edit Settings in Kibana my current index specs are:

{
  "index.blocks.read_only_allow_delete": "false",
  "index.priority": "1",
  "index.query.default_field": [
    "*"
  ],
  "index.write.wait_for_active_shards": "1",
  "index.mapping.total_fields.limit": "10000",
  "index.refresh_interval": "1s",
  "index.number_of_replicas": "0"
}

How can I combine above mentioned while creating my index to get:

{
  "index.blocks.read_only_allow_delete": "false",
  "index.priority": "1",
  "index.query.default_field": [
    "*"
  ],
  "index.write.wait_for_active_shards": "1",
  "index.mapping.total_fields.limit": "10000",
  "index.refresh_interval": "1s",
  "index.mapping.ignore_malformed": "true",
  "index.number_of_replicas": "0"
}

Beside: It is also not possible to add this string by editing in Kibana Result = Bad Request (wtf why!?)

Reference: Empty string in Elasticsearch date field?

How set ignore_malformed in index level when creating an index through ElasticSearch DSL python wrapper?

Thanks for any help Regards

  • Note the error ```true``` is not defined. However ,```True``` should be. May just have been a typo. – ekmcd Aug 25 '20 at 22:29

1 Answers1

0

oh yes, typo error... I reworked the settings, now it works, even on field level :)

settings = {
"settings": {
    "index.refresh_interval" : "1s",
    "index.mapping.total_fields.limit": 10000,
    "number_of_shards": 1,
    "number_of_replicas": 0,
    "index.mapping.ignore_malformed": "true"
  },
"mappings": {
  "properties": {
        "location": {
          "type": "geo_point"
        },
        "Date":{
          "type": "date",
          #"ignore_malformed": "true"
        }
      },
    "dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    ]
  }
}