Hello, I have a UserSearchEntity dto which represents the document for the Elasticsearch. The UserSearchEntity is as follows:
@Document(indexName = "user_index" , type = "user")
public class UserSearchEntity
{
@Id
private String mosaicId;
private String connectoId;
private String city;
private String mobileNumber;
private String professionType;
private double monthlyIncome;
private String designation;
private String lastUpdatedSource;
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = MosaicConstants.DATE_PATTERN)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = MosaicConstants.DATE_PATTERN)
private Date birthDate;
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = MosaicConstants.DATE_PATTERN)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = MosaicConstants.DATE_PATTERN)
private Date creationDate;
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = MosaicConstants.DATE_PATTERN)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = MosaicConstants.DATE_PATTERN)
private Date lastUpdatedDate;
public String getConnectoId() {
return connectoId;
}
public void setConnectoId(String connectoId) {
this.connectoId = connectoId;
}
public String getProfessionType() {
return professionType;
}
public void setProfessionType(String professionType) {
this.professionType = professionType;
}
public double getMonthlyIncome() {
return monthlyIncome;
}
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
public Date getLastUpdatedDate() {
return lastUpdatedDate;
}
public void setLastUpdatedDate(Date lastUpdatedDate) {
this.lastUpdatedDate = lastUpdatedDate;
}
public String getLastUpdatedSource() {
return lastUpdatedSource;
}
public void setLastUpdatedSource(String lastUpdatedSource) {
this.lastUpdatedSource = lastUpdatedSource;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
}
On retrieving the data from the elasticsearchrepository, I am getting following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsQueueConsumer': Unsatisfied dependency expressed through field 'searchService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSearchService': Unsatisfied dependency expressed through field 'userSearchRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Mapper for [birthDate] conflicts with existing mapping in other types:
[mapper [birthDate] has different [format] values]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at java.lang.IllegalArgumentException: Mapper for [birthDate] conflicts with existing mapping in other types:
[mapper [birthDate] has different [format] values]
And the Elasticsearch document is :
"birthDate" : "1984-10-17 06:30:00",
"creationDate" : "2019-05-27 08:55:23",
"lastUpdatedDate" : "2019-05-27 08:55:23"
Please help with this issue.