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
FieldsModifier and TypeFieldDescriptionprotected final BusinessUnitManagerprotected final CommandExecutorprotected final Contextprotected final DataModelprotected final DataSourceprotected final DefaultDisplayServiceprotected booleanprotected List<IndexExtractor> protected intprotected final LocaleResolverServiceprotected final org.slf4j.Loggerprotected final ModuleManagerprotected intprotected final PersistenceServiceprotected final QueryBuilderFactoryprotected final QueryProcessorServiceprotected final SecurityManagerprotected final TaskSchedulingServiceprotected final TextResourcesprotected final TypeManager -
Constructor Summary
ConstructorsConstructorDescriptionAbstractFulltextIndexService(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 voidAdds the specified entity to the index.final booleancheckIndexForEntity(String entityModelName) Check the index for the specified entity model.protected abstract voiddeleteByEntityModel(EntityModel entityModel) protected abstract voiddeleteByIds(List<String> ids) protected abstract voiddeleteByQuery(FulltextSearchQuery fulltextSearchQuery) final voiddeleteEntity(EntityId entityId) Removes the specified entity from the index.protected abstract voiddoAddEntity(Entity entity) protected abstract voiddoDeleteEntity(EntityId entityId) protected abstract voiddoUpdateEntity(Entity entity) protected FulltextSearchResponseImplfilterEntityTypes(FulltextSearchResponseImpl fulltextSearchResponse) final voidfixIndex()voidfixIndexForEntity(String entityModelName) getExtractorResult(Entity entity) protected intgetIndexPriority(EntityModel entityModel) protected abstract voidhandleIndexingForEntity(EntityList entityList) protected abstract FulltextSearchResponseImplhandleQuery(FulltextSearchQuery fulltextSearchQuery) protected FulltextSearchResponseImplhandleSecurity(FulltextSearchQuery fulltextSearchQuery, FulltextSearchResponseImpl fulltextSearchResponse) protected booleanisIndexed(EntityModel entityModel) protected FulltextSearchQueryprepareQuery(FulltextSearchQuery fulltextSearchQuery) final FulltextSearchResponsequery(FulltextSearchQuery fulltextSearchQuery) Query the index with the specified fulltext search query.protected <T> TrunAsAnonymous(Callable<T> callable) Executes a callable with anonymous principal.final voidCheck the whole index.final voidDo a complete indexing of the whole database.final voidrunIndexingForEntity(String entityModelName) Do indexing of the specified entity model.voidsetExtractors(List<IndexExtractor> indexExtractors) protected FulltextSearchQuerysetIndexFixPagingParams(FulltextSearchQuery fulltextSearchQuery, int limit, PagedLoader.StartParam<FulltextSearchResponse.Document> startParam) Override this method to set different paging params than limit and offset (e.g.final voidupdateEntity(Entity entity) Updates the specified entity to the index.booleanwasTaskRun(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, waitMethods 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 -
indexTaskPartitionSize
@VisibleForTesting @Value("${nice2.enterprisesearch.indexfix.indexTaskPartitionSize}") protected int indexTaskPartitionSize
-
-
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:FulltextIndexServiceAdds the specified entity to the index. This is / should used only internally by updating listener.- Specified by:
addEntityin interfaceFulltextIndexService- Parameters:
entity- a entity to do the specified operation with
-
doAddEntity
-
updateEntity
Description copied from interface:FulltextIndexServiceUpdates the specified entity to the index. This is / should used only internally by updating listener.- Specified by:
updateEntityin interfaceFulltextIndexService- Parameters:
entity- a entity to do the specified operation with
-
doUpdateEntity
-
deleteEntity
Description copied from interface:FulltextIndexServiceRemoves the specified entity from the index. This is / should used only internally by updating listener.- Specified by:
deleteEntityin interfaceFulltextIndexService- Parameters:
entityId- an entity-id to do the specified operation with
-
doDeleteEntity
-
runCompleteIndexing
public final void runCompleteIndexing()Description copied from interface:FulltextIndexServiceDo 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:
runCompleteIndexingin interfaceFulltextIndexService- See Also:
-
deleteByEntityModel
-
runIndexingForEntity
Description copied from interface:FulltextIndexServiceDo indexing of the specified entity model.- Specified by:
runIndexingForEntityin interfaceFulltextIndexService- Parameters:
entityModelName- a valid entity model name- See Also:
-
runCompleteIndexCheck
public final void runCompleteIndexCheck()Description copied from interface:FulltextIndexServiceCheck 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:
runCompleteIndexCheckin interfaceFulltextIndexService- See Also:
-
checkIndexForEntity
Description copied from interface:FulltextIndexServiceCheck the index for the specified entity model.- Specified by:
checkIndexForEntityin interfaceFulltextIndexService- Parameters:
entityModelName- a valid entity model name- See Also:
-
fixIndex
public final void fixIndex()- Specified by:
fixIndexin 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:FulltextIndexServicereturns true if the task already ran for the current revision- Specified by:
wasTaskRunin interfaceFulltextIndexService
-
query
Description copied from interface:FulltextIndexServiceQuery the index with the specified fulltext search query.- Specified by:
queryin 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).
-