【发布时间】:2017-06-26 12:45:36
【问题描述】:
我有这样的模型:
@Getter
@Setter
@Document(indexName = "indexName", type = "typeName")
@Setting(settingPath = "/elastic/elastic-setting.json")
public class Model extends BaseModel {
@Field(type = FieldType.String, index = FieldIndex.analyzed, analyzer = "customAnalyzer")
private String name;
}
我在 ../resources/elastic/elastic-setting.json 中有 elastic-setting.json:
{
"index": {
"number_of_shards": "1",
"number_of_replicas": "0",
"analysis": {
"analyzer": {
"customAnalyzer": {
"type": "custom",
"tokenizer": "uax_url_email"
}
}
}
}
}
我清理了我的弹性数据库,当我启动我的应用程序时出现异常:
MapperParsingException[analyzer [customAnalyzer] not found for field [name]]
我的代码有什么问题? 请帮帮我!
编辑
Val,我认为@Setting 就像是对@Document 的补充,但看起来它们可以互换。 就我而言,我还有另一个模型,带有:
@Document(indexName = "indexName", type = "anotherTypeName")
所以,首先我为另一个模型创建名为“indexName”的索引,然后在弹性准备模型时,它看到,名称为“indexName”的索引已经创建,他不使用@Setting。
现在我还有一个问题。 如何将自定义分析器添加到 java 代码中已创建的索引,例如在 InitializingBean 中。类似的东西 - 我的分析仪是创建的吗?不 - 创建。是 - 不要创建。
【问题讨论】:
标签: elasticsearch spring-boot spring-data spring-data-elasticsearch