Class SearchService


  • @Singleton
    public class SearchService
    extends Object
    Provides methods to initialize search indexes and do search against them.
    • Constructor Detail

      • SearchService

        public SearchService()
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Whether full-text search support is enabled.
      • createIndex

        public void createIndex​(boolean force)
                         throws InterruptedException
        Initialize search indexes if not created yet, unless forced.
        Parameters:
        force - if true, indexes will be re-created.
        Throws:
        InterruptedException
      • doSearch

        public void doSearch​(Consumer<org.hibernate.search.jpa.FullTextEntityManager> runner)
        Perform full-text search.
        Parameters:
        runner - the search runner
      • fullTextSearch

        public List<Long> fullTextSearch​(Class<? extends Model> entityType,
                                         String searchText,
                                         int limit)
                                  throws IOException
        Do full-text search on the given entity type with the given search text.

        The method will do search in batches and apply security filter on them until max records are not found or there are no more records to search.

        Parameters:
        entityType - the entity type to search on
        searchText - the search text
        limit - maximum number of result
        Returns:
        list of record ids
        Throws:
        IOException - if any error reading indexes