Spring Repository: PropertyReferenceException: No property [name] for type [class]

Viewed 67

I'm trying to create custom elasticsearch repository to an existing Spring Boot App. However, I'm facing the PropertyReferenceException exception no matter what I change the names of the Implementation classes and interfaces.

All the solutions mentioned here and here don't seem to work for me.

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAllComponents found for type EsComponentSearch!

Base interface:

@Repository
public interface EsComponentSearchRepository
        extends ElasticsearchRepository<EsComponentSearch, String>, EsComponentSearchRepositoryCustom {

}

EsComponentSearchRepositoryCustom.java

public interface EsComponentSearchRepositoryCustom {
    List<EsComponentSearch> findAllComponents(List<String> searchTerms);
}

EsComponentSearchRepositoryImpl.java:

public class EsComponentSearchRepositoryImpl implements EsComponentSearchRepositoryCustom {

    private final ElasticsearchRestTemplate elasticsearchRestTemplate;

    public EsComponentSearchRepositoryImpl(ElasticsearchRestTemplate elasticsearchRestTemplate) {
        this.elasticsearchRestTemplate = Objects.requireNonNull(elasticsearchRestTemplate);
    }

    @Override
    public List<EsComponentSearch> findAllComponents(List<String> searchTerms) {

        MultiMatchQueryBuilder multiMatchQueryBuilder = new MultiMatchQueryBuilder(searchTerms.get(0), "component_name");

        Query query = new NativeSearchQueryBuilder().withQuery(multiMatchQueryBuilder).build();

        SearchHits<EsComponentSearchDashboard> searchHits = elasticsearchRestTemplate.search(query,
                EsComponentSearch.class, "components"));

        searchHits.getTotalHits();

//TODO
        return null;
    }
}

Both the interfaces are in the same package and the configuration class is:

@Configuration
@EnableElasticsearchRepositories(basePackages = "com.elasticsearch.repository.api")
public class SearchESConfig extends AbstractElasticsearchConfiguration {

Can anyone point what am I missing here?

0 Answers
Related