映射器与现有映射器有冲突例如:Mapper for [composeGoodName] conflicts with existing mapping in other types:

说来惭愧,这本是一个不应该出现的错误:
pojo类中的部分代码:让composeGoodName使用ik分词器。

@Document(indexName = "seasonal",type = "escomposegood", shards = 4, replicas = 0)
public class ESComposeGood {
    @Id
    private Long id;
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String composeGoodName;
    @Field(type = FieldType.Integer)
    private Integer composeGoodPrice;
    @Field(type = FieldType.Long)
    private Long composeGoodType;
    @Field(type = FieldType.Integer)
    private Integer composeGoodStatus;
    @Field(type = FieldType.Integer)
    private Integer composeGoodWeight;
    @Field(type = FieldType.Keyword)
    private String composeGoodIcon;
    @Field(type = FieldType.Integer)
    private Integer composeGoodSales;
    }
   

意外发生了,程序跑不起来了,他告诉我:

[mapper [composeGoodName] has different [analyzer]]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource 
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ESComposeGoodResitory': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is 
java.lang.IllegalArgumentException:
 Mapper for [composeGoodName] conflicts with existing mapping in other types:(这句才是错误的核心)

一番查找后发现如果在使用分词器之前将数据插入了Elasticsearch那么就会发生Elasticsearch无法解析的问题,也就是上述错误所以说:
解决方案:
在向Elasticsearch中插入数据之前就要给需要的进行分词的属性标记好解析,然后再插入数据即可解决问题!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值