Package 

Interface SearchDescriptor


  • 
    public interface SearchDescriptor<T extends Object>
    
                        

    Search Descriptor allows exposing automatically a search endpoint for an 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 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:

    @Configuration
    public class SearchDescriptorConfiguration implements SearchConfigurer {
    
      @Override
      public void addSearchDescriptors(SearchDescriptorRegistry registry) {
        SearchDescriptor searchDescriptor = new SearchDescriptorBuilder<Person>(Person.class).build();
        registry.addSearchDescriptor(searchDescriptor);
      }
    }
    • Another solution is to add a new @Bean. This solution is useful when you want to create a SearchDescriptor which depends on other Beans:

    @Configuration
    public class SearchDescriptorConfiguration {
      @Bean
      SearchDescriptor<Person> personSearchDescriptor(PersonRepository personRepository) {
        return new SearchDescriptorBuilder<Person>(Person.class)
                         .specificationExecutor(personRepository)
                         .build();
      }
    }