python - 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”:true,我得到: NameError:name 'true' is not defined
通过以下操作,我可以执行此设置,但在索引时我需要同时执行这两个设置:
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 Result = Bad Request 中编辑来添加此字符串(为什么!?)
通过 ElasticSearch DSL python 包装器创建索引时,如何在索引级别设置 ignore_malformed?
感谢您的帮助问候
解决方案
哦,是的,错字错误...我重新设置了设置,现在它可以工作了,即使在现场级别:)
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
}
}
}
}
}
]
}
}
推荐阅读
- javascript - 将 API 中的 JSON 数据保存到数据库中并缓存请求,因此我不需要再次从 API 请求 - Node.js / Express.js
- c# - 我有 ac# 一个控制台应用程序,我需要将其转换为 Azure 函数
- python - 在 Pyspark 上运行 K-Means
- scala - 如何将尾递归方法转换为更类似于 Scala 的函数?
- r - Data.Table 列的非零值
- ruby-on-rails - 来自对 Rails 主动存储 API 做出反应的“未经许可的参数”
- html - 使用 div 元素使我的按钮居中
- certificate - Quarkus - 使用 Postman 查询受 TLS/SSL 保护的资源
- python - 使用基于时间的分桶快速将数据帧保存到 mongodb?
- qt-creator - 更改 Qt Creator 界面缩放/字体大小