public static class SearchDescriptor.DefaultImpls
Search Descriptor allows exposing automatically a search endpoint for a JPA Entity.
The new endpoint is mapped to /search/{searchDescriptorId}
where searchDescriptorId
is the id
specified in the SearchDescriptor
.
The easiest way to create a Search Descriptor is to use the class SearchDescriptorBuilder
which provides every options available to configure a SearchDescriptor
.
To expose the new Entity search endpoint, SearchDescriptor
must be registered to the Spring Data Search Configuration:
Implement the interface SearchConfigurer
interface and override the com.weedow.spring.data.search.config.SearchConfigurer.addSearchDescriptors
method:
@Configuration
public class SearchDescriptorConfiguration implements SearchConfigurer {
@Override
public void addSearchDescriptors(SearchDescriptorRegistry registry) {
SearchDescriptor searchDescriptor = new SearchDescriptorBuilder(Person.class).build();
registry.addSearchDescriptor(searchDescriptor);
}
}
Another solution is to add a new annotationclass Bean
. This solution is useful when you want to create a SearchDescriptor
which depends on other Beans:
@Configuration
public class SearchDescriptorConfiguration {
@Bean
SearchDescriptor personSearchDescriptor(PersonRepository personRepository) {
return new SearchDescriptorBuilder(Person.class)
.jpaSpecificationExecutor(personRepository)
.build();
}
}
@NotNull public static java.util.List<com.weedow.spring.data.search.validation.DataSearchValidator> getValidators(SearchDescriptor<T> $this)
Returns list of interface DataSearchValidator
to validate the request parameters.
interface DataSearchValidator