I have made an entity in spring boot using @Document and @Entity annotation. Code goes like :-
// Code
@Entity
@Document(indexName = "content", type = "doc")
public class Content implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long contentId;
@Field(type = Date)
@Column(updatable=false, insertable=false)
private LocalDateTime dateAdded;
@Field(type = Date)
@Column(updatable=false, insertable=false)
private LocalDateTime dateModified;
...... With getter and setter basically. Normal POJO basically.
}
And i have made the repository using :-
//Code
@Repository
public interface ElasticSearch extends ElasticsearchRepository<Content, Long>{
@Query("{"bool": {"must": [{"match": {"authors.name": "?0"}}]}}")
Page findByAuthorsNameUsingCustomQuery(String name, Pageable pageable);
@Query("{"bool": {"must": {"match_all": {}}, "filter": {"term": {"tags": "?0" }}}}")
Page vf(String tag, Pageable pageable);
@Query("{"bool": {"must": {"match": {"authors.name": "?0"}}, "filter": {"term": {"tags": "?1" }}}}")
Page findByAuthorsNameAndFilteredTagQuery(String name, String tag, Pageable pageable);
}
But as soon as I am running my spring boot application my system is giving error like :-
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentController': Unsatisfied dependency expressed through field 'contentSearchService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentSearchImpl': Unsatisfied dependency expressed through field 'contentSearch'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contentSearch': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.lang.Object org.springframework.data.elasticsearch.repository.ElasticsearchRepository.index(java.lang.Object)! No property index found for type Content! at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
I have tried many things. Can someone please help with this.