Package com.axelor.db.search
Class SearchService
- java.lang.Object
-
- com.axelor.db.search.SearchService
-
@Singleton public class SearchService extends Object
Provides methods to initialize search indexes and do search against them.
-
-
Constructor Summary
Constructors Constructor Description SearchService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateIndex(boolean force)Initialize search indexes if not created yet, unless forced.voiddoSearch(Consumer<org.hibernate.search.jpa.FullTextEntityManager> runner)Perform full-text search.List<Long>fullTextSearch(Class<? extends Model> entityType, String searchText, int limit)Do full-text search on the given entity type with the given search text.booleanisEnabled()Whether full-text search support is enabled.
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
Whether full-text search support is enabled.
-
createIndex
public void createIndex(boolean force) throws InterruptedExceptionInitialize 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 onsearchText- the search textlimit- maximum number of result- Returns:
- list of record ids
- Throws:
IOException- if any error reading indexes
-
-