ES索引与python-结合常规映射设置含 index.mapping.ignore_malformed

问题描述

在尝试将ignore_malformed添加到索引设置时,我需要帮助。

我有:

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)

如果我尝试添加“ index.mapping.ignore_malformed”:是的, 我得到: NameError:未定义名称“ true”

通过执行以下操作,我可以执行此设置,但在索引编制时我需要同时进行这两项设置

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()

在Kibana的“编辑设置”下,我当前的索引规格为:

{
  "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"
}

在创建索引时如何结合上述内容:

{
  "index.blocks.read_only_allow_delete": "false","index.mapping.ignore_malformed": "true","index.number_of_replicas": "0"
}

旁边: 也无法通过在Kibana中进行编辑来添加此字符串 结果=错误的请求(wtf为什么!?)

参考: Empty string in Elasticsearch date field?

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

感谢您的帮助 问候

解决方法

哦,是的,输入错误... 我重新设置了这些设置,现在就可以使用了,即使在字段级别:)

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
              }
            }
          }
        }
      }
    ]
  }
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...