在尝试将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.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"
}
旁:
也无法通过在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
              }
            }
          }
        }
      }
    ]
  }
}

关于python - ES索引与python-结合常规映射设置(含)。 index.mapping.ignore_malformed,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63587784/

10-10 18:26
查看更多