当更新添加新字段时,弹性搜索不遵循映射

时间:2015-10-16 03:01:24

标签: python templates dynamic elasticsearch updates

使用python update 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"仍然以某种方式"分析"。我试图将新字段明确地添加到模板中,但这也无济于事。

1 个答案:

答案 0 :(得分:0)

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