无法将非对象映射[suggest]与对象映射[suggest]合并

时间:2017-02-23 12:00:03

标签: spring unit-testing spring-data-elasticsearch search-suggestion

我使用Spring和Elastic Search。我有Completion字段的实体,用于建议:

@Document(indexName = "entity_index", type = "entity")
public class Entity {
@Id
private Long id;

....

@CompletionField(maxInputLength = 30,payloads = true)
private Completion suggest;
...

}

当我启动Spring Boot应用程序时 - 一切都很好,没有错误。 但是当我想开始我的弹性搜索单元测试时,我得到错误:

Failed to load Application Context

....

java.lang.IllegalArgumentException: Can't merge a non object mapping [suggest] with an object mapping [suggest]

所以,请帮我解决这个问题

2 个答案:

答案 0 :(得分:0)

我通过删除包含elasticsearch数据的data文件夹解决了这个问题。

答案 1 :(得分:0)

您不能更改现有映射。

如果您可能会丢失数据,请删除索引,然后使用新的映射重新创建索引。 如果您需要保留数据-使用新映射创建新索引,并将数据从旧索引复制到新索引-它们将旧索引更新为日期,并使用旧名称创建别名以指向新索引

在您的情况下,我怀疑您创建的索引的字段未标记为@CompletionField,以后又添加了注释,以及为什么会看到该错误。

相关问题