【问题标题】:elastic search does not obey mapping when update adds a new field更新添加新字段时弹性搜索不服从映射
【发布时间】:2015-10-16 03:01:24
【问题描述】:

使用 python 更新 API,我将一个字符串字段添加到我的 ES 索引文档中。 甚至我的映射也有这个:

"mappings" : {
    "_default_": {
            "dynamic_templates": [
                { "notanalyzed": {
                      "match":              "*", 
                      "match_mapping_type": "string",
                      "mapping": {
                          "type":        "string",
                          "index":       "not_analyzed"
                      }
                   }
                }
              ]
    },

新添加的字段仍在分析中。有人注意到同样的问题吗?

这是一段添加新列的python代码:

res = es.search(index=ind, body=st, size=2000) for rec in res['hits']['hits']: es.update(index=rec['_index'],doc_type=rec['_type'],id=rec['_id'], body={"doc": {"srcSite": sS}})

所以新添加的“srcSite”仍然以某种方式“分析”。我尝试将新字段显式添加到模板中,但这也无济于事。

【问题讨论】:

  • 你的相关python代码是什么样子的?另外请分享一个示例文档和您的字符串字段的有效映射。

标签: python templates dynamic elasticsearch updates


【解决方案1】:

啊,我发现了问题所在。似乎模板在创建文档时以某种方式得到修复,以后更改模板不会改变任何内容 - 即使更新文档,它也不会使用更改后的模板,而是使用原始模板...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多