1
votes

I am trying to use faceted search with a custom repository as follows:

Repository:

public interface POISearchRepository extends CustomSolrRepository, SolrCrudRepository<POISearch, String>

Custom interface:

public interface CustomSolrRepository { 

     FacetPage<POISearch> facetSearch(String location, String categories, String duration, Pageable page) throws Exception; 
}

Custom impl:

@Repository
public class POISearchImpl implements CustomSolrRepository {

@Resource
private SolrTemplate solrTemplate;

@Override
public FacetPage<POISearch> facetSearch(String location, String categories, String duration, Pageable page) throws Exception {

......
}

Unfortunately, I keep getting the following exception:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property facet found for type com.example.domain.POISearch at org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) at org.springframework.data.repository.query.parser.Part.(Part.java:72) at org.springframework.data.repository.query.parser.PartTree$OrPart.(PartTree.java:180) at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260) at org.springframework.data.repository.query.parser.PartTree$Predicate.(PartTree.java:240) at org.springframework.data.repository.query.parser.PartTree.(PartTree.java:68) at org.springframework.data.solr.repository.query.PartTreeSolrQuery.(PartTreeSolrQuery.java:36) at org.springframework.data.solr.repository.support.SolrRepositoryFactory$SolrQueryLookupStrategy.resolveQuery(SolrRepositoryFactory.java:101) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.(RepositoryFactorySupport.java:279) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ... 57 more

It seems like the repository tries to resolve the custom method and that causes the exception (changing the method names shows that)

1

1 Answers

2
votes

The problem was with the naming for my repository intrefaces. Fixes:

Repository : POISearchRepository Custom interface: POISearchRepositoryCustom Customer implementation: POISearchRepositoryImpl

My initial naming was not according to Spring Data spec