Class AbstractFulltextIndexService<T>
java.lang.Object
ch.tocco.nice2.enterprisesearch.impl.AbstractFulltextIndexService<T>
- All Implemented Interfaces:
FulltextIndexService
- Direct Known Subclasses:
ElasticSearchFulltextIndexService
,FakeFulltextIndexService
public abstract class AbstractFulltextIndexService<T>
extends Object
implements FulltextIndexService
This abstract class contains all generic code which could use any enterprise search system.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final BusinessUnitManager
protected final CommandExecutor
protected final Context
protected final DataModel
protected final DataSource
protected final DefaultDisplayService
protected boolean
protected List
<IndexExtractor> protected final LocaleResolverService
protected final org.slf4j.Logger
protected final ModuleManager
protected int
protected final PersistenceService
protected final QueryBuilderFactory
protected final QueryProcessorService
protected final SecurityManager
protected final TaskSchedulingService
protected final TextResources
protected final TypeManager
-
Constructor Summary
ConstructorDescriptionAbstractFulltextIndexService
(DataModel dataModel, Context context, PersistenceService persistenceService, QueryProcessorService queryProcessorService, DefaultDisplayService defaultDisplayService, BusinessUnitManager businessUnitManager, QueryBuilderFactory queryBuilderFactory, SecurityManager securityManager, LocaleResolverService localeResolverService, TaskSchedulingService taskSchedulingService, DataSource dataSource, TextResources textResources, TypeManager typeManager, org.slf4j.Logger logger, CommandExecutor commandExecutor, ModuleManager moduleManager) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds the specified entity to the index.final boolean
checkIndexForEntity
(String entityModelName) Check the index for the specified entity model.protected abstract void
deleteByEntityModel
(EntityModel entityModel) protected abstract void
deleteByIds
(List<String> ids) protected abstract void
deleteByQuery
(FulltextSearchQuery fulltextSearchQuery) final void
deleteEntity
(EntityId entityId) Removes the specified entity from the index.protected abstract void
doAddEntity
(Entity entity) protected abstract void
doDeleteEntity
(EntityId entityId) protected abstract void
doUpdateEntity
(Entity entity) protected FulltextSearchResponseImpl
filterEntityTypes
(FulltextSearchResponseImpl fulltextSearchResponse) final void
fixIndex()
void
fixIndexForEntity
(String entityModelName) getExtractorResult
(Entity entity) protected int
getIndexPriority
(EntityModel entityModel) protected abstract void
handleIndexingForEntity
(EntityList entityList) protected abstract FulltextSearchResponseImpl
handleQuery
(FulltextSearchQuery fulltextSearchQuery) protected FulltextSearchResponseImpl
handleSecurity
(FulltextSearchQuery fulltextSearchQuery, FulltextSearchResponseImpl fulltextSearchResponse) protected boolean
isIndexed
(EntityModel entityModel) protected FulltextSearchQuery
prepareQuery
(FulltextSearchQuery fulltextSearchQuery) final FulltextSearchResponse
query
(FulltextSearchQuery fulltextSearchQuery) Query the index with the specified fulltext search query.protected <T> T
runAsAnonymous
(Callable<T> callable) Executes a callable with anonymous principal.final void
Check the whole index.final void
Do a complete indexing of the whole database.final void
runIndexingForEntity
(String entityModelName) Do indexing of the specified entity model.void
setExtractors
(List<IndexExtractor> indexExtractors) protected FulltextSearchQuery
setIndexFixPagingParams
(FulltextSearchQuery fulltextSearchQuery, int limit, PagedLoader.StartParam<FulltextSearchResponse.Document> startParam) Override this method to set different paging params than limit and offset (e.g.final void
updateEntity
(Entity entity) Updates the specified entity to the index.boolean
wasTaskRun
(String taskName) returns true if the task already ran for the current revisionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.enterprisesearch.api.FulltextIndexService
fetchSuggestions, setupIndex, truncateIndex
-
Field Details
-
dataModel
-
context
-
persistenceService
-
queryProcessorService
-
defaultDisplayService
-
businessUnitManager
-
queryBuilderFactory
-
securityManager
-
localeResolverService
-
taskSchedulingService
-
dataSource
-
textResources
-
typeManager
-
logger
protected final org.slf4j.Logger logger -
commandExecutor
-
moduleManager
-
extractors
-
exclusiveOperationInProgress
protected volatile boolean exclusiveOperationInProgress -
pageLoaderPartitionSize
@VisibleForTesting @Value("${nice2.enterprisesearch.indexfix.queryPartitionSize}") protected int pageLoaderPartitionSize
-
-
Constructor Details
-
AbstractFulltextIndexService
public AbstractFulltextIndexService(DataModel dataModel, Context context, PersistenceService persistenceService, QueryProcessorService queryProcessorService, DefaultDisplayService defaultDisplayService, BusinessUnitManager businessUnitManager, QueryBuilderFactory queryBuilderFactory, SecurityManager securityManager, LocaleResolverService localeResolverService, TaskSchedulingService taskSchedulingService, DataSource dataSource, TextResources textResources, TypeManager typeManager, org.slf4j.Logger logger, CommandExecutor commandExecutor, ModuleManager moduleManager)
-
-
Method Details
-
setExtractors
-
addEntity
Description copied from interface:FulltextIndexService
Adds the specified entity to the index. This is / should used only internally by updating listener.- Specified by:
addEntity
in interfaceFulltextIndexService
- Parameters:
entity
- a entity to do the specified operation with
-
doAddEntity
-
updateEntity
Description copied from interface:FulltextIndexService
Updates the specified entity to the index. This is / should used only internally by updating listener.- Specified by:
updateEntity
in interfaceFulltextIndexService
- Parameters:
entity
- a entity to do the specified operation with
-
doUpdateEntity
-
deleteEntity
Description copied from interface:FulltextIndexService
Removes the specified entity from the index. This is / should used only internally by updating listener.- Specified by:
deleteEntity
in interfaceFulltextIndexService
- Parameters:
entityId
- an entity-id to do the specified operation with
-
doDeleteEntity
-
runCompleteIndexing
public final void runCompleteIndexing()Description copied from interface:FulltextIndexService
Do a complete indexing of the whole database. It iterates over all entity types and starts with the ones with the highest indexing-priority. Entity types with indexing-priority of -1 are not included. This method can only be executed once per instance.- Specified by:
runCompleteIndexing
in interfaceFulltextIndexService
- See Also:
-
deleteByEntityModel
-
runIndexingForEntity
Description copied from interface:FulltextIndexService
Do indexing of the specified entity model.- Specified by:
runIndexingForEntity
in interfaceFulltextIndexService
- Parameters:
entityModelName
- a valid entity model name- See Also:
-
runCompleteIndexCheck
public final void runCompleteIndexCheck()Description copied from interface:FulltextIndexService
Check the whole index. It checks first if the count of a entity model matches (database vs. index) and the checks the version of each record. This method can only be executed once per instance.- Specified by:
runCompleteIndexCheck
in interfaceFulltextIndexService
- See Also:
-
checkIndexForEntity
Description copied from interface:FulltextIndexService
Check the index for the specified entity model.- Specified by:
checkIndexForEntity
in interfaceFulltextIndexService
- Parameters:
entityModelName
- a valid entity model name- See Also:
-
fixIndex
public final void fixIndex()- Specified by:
fixIndex
in interfaceFulltextIndexService
-
fixIndexForEntity
-
setIndexFixPagingParams
protected FulltextSearchQuery setIndexFixPagingParams(FulltextSearchQuery fulltextSearchQuery, int limit, PagedLoader.StartParam<FulltextSearchResponse.Document> startParam) Override this method to set different paging params than limit and offset (e.g. `#searchAfter()`) -
wasTaskRun
Description copied from interface:FulltextIndexService
returns true if the task already ran for the current revision- Specified by:
wasTaskRun
in interfaceFulltextIndexService
-
query
Description copied from interface:FulltextIndexService
Query the index with the specified fulltext search query.- Specified by:
query
in interfaceFulltextIndexService
- Parameters:
fulltextSearchQuery
- a fulltext search query object- Returns:
- a fulltext search response object
-
handleIndexingForEntity
-
handleQuery
-
deleteByQuery
-
deleteByIds
-
prepareQuery
-
filterEntityTypes
protected FulltextSearchResponseImpl filterEntityTypes(FulltextSearchResponseImpl fulltextSearchResponse) -
handleSecurity
protected FulltextSearchResponseImpl handleSecurity(FulltextSearchQuery fulltextSearchQuery, FulltextSearchResponseImpl fulltextSearchResponse) -
isIndexed
-
getIndexPriority
-
getExtractorResult
-
runAsAnonymous
Executes a callable with anonymous principal. Should be used when adding data to index. Otherwise records may contain "personalized" data (like entity marking).
-