我对索引类型中属性的更新分析器有疑问。我已经阅读了此类错误的问题here .但事实并非如此,因为我只有一种索引类型(试验),而且它是独一无二的,不可能发生冲突。这是来自 elasticsearch 2.3。
映射
(get "/public-search/_mapping/developer")
{:public-search {:mappings {:developer {:properties {:db/id {:type "long"}, :developer/description {:type "string"}, :developer/established-date {:type "date", :format "strict_date_optional_time||epoch_millis"}, :developer/logo-url {:type "string"}, :developer/name {:type "string"}, :developer/total-project {:type "long"}}}}}}
// I do have autocomplete analyzer in settings
(put "/public-search/_mapping/developer"
{:properties {:developer/name {:type "string"
:analyzer "autocomplete"}}})
{:error {:root_cause [{:type "illegal_argument_exception", :reason "Mapper for [developer/name] conflicts with existing mapping in other types:\n[mapper [developer/name] has different [analyzer]]"}], :type "illegal_argument_exception", :reason "Mapper for [developer/name] conflicts with existing mapping in other types:\n[mapper [developer/name] has different [analyzer]]"}, :status 400}
如果我在将数据放入其中之前创建映射就可以正常工作。但我仍然担心在运行时更新映射。 在这种情况下可能出了什么问题?
最佳答案
如果我在将数据放入其中之前创建映射就可以正常工作。
这只是说明了一切,不是吗?
如果你第一次插入数据时没有映射,ES 会猜测你的数据类型,然后根据它创建映射。查看 ES 为您的数据生成的映射。
我建议,这并不是您想要创建的映射。
简单示例:插入“字符串”2016-01-01T00:00:00.000Z
。 ES 将创建一个日期时间字段,即使您想要一个字符串字段。为了获得字符串字段,您必须在插入数据之前创建映射。
另外还有analyzers等ES是无法猜到的。而且(如果我没记错的话)在插入数据后不可能覆盖它们。
关于java - 与现有映射冲突的映射器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37628981/