Class ElasticSearchComponent
- All Implemented Interfaces:
ElasticSearchAdmin,ElasticSearchIndexing,ElasticSearchService,Adaptable,Component,Extensible,TimestampedService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ElasticSearchClientConfigprotected ElasticSearchEmbeddedServerConfigprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected ElasticSearchAdminImplprotected ElasticSearchIndexingImplprotected ElasticSearchServiceImplprotected final Map<String,ElasticSearchIndexConfig> protected JsonESDocumentWriterprotected static final longprotected final AtomicIntegerprotected final List<IndexingCommand>protected com.google.common.util.concurrent.ListeningExecutorServiceFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearScroll(EsScrollResult scrollResult) Clear scroll on ElasticSearch cluster for the givenEsScrollResult.protected voiddispatchWork(List<IndexingCommand> cmds) Dispatch jobs between sync and async workervoiddropAndInitIndex(String indexName) Reinitialize an index.voiddropAndInitRepositoryIndex(String repositoryName, boolean syncAlias) Reinitialize the index of a repository.voidflush()Elasticsearch flush on all document indexes, triggers a lucene commit, empties the transaction log.voidflushRepositoryIndex(String repositoryName) Elasticsearch flush on document index for a specific repository, triggers a lucene commit, empties the transaction log.intThe component notification order forComponent.start(ComponentContext).Retrieves theClientthat can be used to access Elasticsearch APIgetHintByOperator(String name) Returns the hint by the Elasticsearch operator name.getIndexNameForRepository(String repositoryName) Get the search index name associated with the repository name.getIndexNameForType(String type) Get the first search index name with the given type.getIndexNamesForType(String type) Get the index names with the given type.longReturns the number of indexing worker scheduled waiting to be executed.getRepositoryForIndex(String indexName) Gets the repository name associated with the index.List repository names that have Elasticsearch support.longReturns the number of indexing worker that are currently running.getSecondaryWriteIndexName(String searchIndexName) Returns the secondary write index used during re-indexing with aliases.intReturns the total number of command processed by Elasticsearch for this Nuxeo instance.getWriteIndexName(String searchIndexName) Returns the index to use for any write operations.voidindexNonRecursive(List<IndexingCommand> cmds) Same asElasticSearchIndexing.indexNonRecursive(org.nuxeo.elasticsearch.commands.IndexingCommand)but process the list command using a bulk request.voidProcess theIndexingCommand.voidinitIndexes(boolean dropIfExists) Initialize Elasticsearch indexes.protected voidvoidinitRepositoryIndexWithAliases(String repositoryName) Creates a new index for the repository applying the mapping and settings.protected booleanbooleanReturns true if the Elasticsearch is embedded with Nuxeo, sharing the same JVM.booleanReturns true if there are indexing activities scheduled or running.booleanisReady()voidoptimize()Elasticsearch runElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String)on all document indexes,voidoptimizeIndex(String indexName) Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.voidoptimizeRepositoryIndex(String repositoryName) Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.com.google.common.util.concurrent.ListenableFuture<Boolean>AFuturethat accepts callback on completion when all the indexing worker are done.query(NxQueryBuilder queryBuilder) Returns a document list using anNxQueryBuilder.queryAndAggregate(NxQueryBuilder queryBuilder) Returns documents and aggregates.voidrefresh()Refresh all document indexes, immediately after the operation occurs, so that the updated document appears in search results immediately.voidrefreshRepositoryIndex(String repositoryName) Refresh document index for the specific repository, immediately after the operation occurs, so that the updated document appears in search results immediately.voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) protected voidvoidreindexRepository(String repositoryName) Recreate an index and run an async reindexing worker.protected voidrunIndexingSyncWorker(Map<String, List<IndexingCommand>> syncCommands) voidrunIndexingWorker(List<IndexingCommand> cmds) Run a worker to process theIndexingCommand.voidrunReindexingWorker(String repositoryName, String nxql, boolean syncAlias) Reindex documents matching the NXQL query, This is done in an asynchronous job.protected voidscheduleIndexingAsyncWorker(Map<String, List<IndexingCommand>> asyncCommands) scroll(EsScrollResult scrollResult) Retrieves the next batch of results of a scrollable search request for the givenEsScrollResult.scroll(NxQueryBuilder queryBuilder, long keepAlive) Performs the initial search of a scrollable search request using anNxQueryBuilder.protected voidorg.opensearch.common.bytes.BytesReferencesource(DocumentModel doc) Returns the JSON Elasticsearch source representation of a document.protected voidstackCommands(List<IndexingCommand> cmds) voidstart(ComponentContext context) Start the component.voidstop(ComponentContext context) Stop the component.voidsyncSearchAndWriteAlias(String searchIndexName) Make sure that the search alias point to the same index as the write alias.booleanWhen true use an external version for Elasticsearch document, this enable an optimistic concurrency control ensuring that an older version of a document never overwrites a newer version.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.elasticsearch.api.ElasticSearchAdmin
dropAndInitRepositoryIndexMethods inherited from interface org.nuxeo.elasticsearch.api.ElasticSearchIndexing
runReindexingWorker
-
Field Details
-
EP_EMBEDDED_SERVER
- See Also:
-
EP_CLIENT_INIT
- See Also:
-
EP_INDEX
- See Also:
-
EP_DOC_WRITER
- See Also:
-
EP_HINTS
- Since:
- 11.1
- See Also:
-
REINDEX_TIMEOUT
protected static final long REINDEX_TIMEOUT- See Also:
-
stackedCommands
-
indexConfig
-
runIndexingWorkerCount
-
embeddedServerConfig
-
clientConfig
-
esa
-
esi
-
ess
-
jsonESDocumentWriter
-
waiterExecutorService
protected com.google.common.util.concurrent.ListeningExecutorService waiterExecutorService
-
-
Constructor Details
-
ElasticSearchComponent
public ElasticSearchComponent()
-
-
Method Details
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
registerContributionin classDefaultComponent
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent
-
reindexOnStartup
protected void reindexOnStartup() -
isElasticsearchEnabled
protected boolean isElasticsearchEnabled() -
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:ComponentThe component notification order forComponent.start(ComponentContext).Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
getClient
Description copied from interface:ElasticSearchAdminRetrieves theClientthat can be used to access Elasticsearch API- Specified by:
getClientin interfaceElasticSearchAdmin
-
initIndexes
public void initIndexes(boolean dropIfExists) Description copied from interface:ElasticSearchAdminInitialize Elasticsearch indexes. Setup the index settings and mapping for each index that has been registered.- Specified by:
initIndexesin interfaceElasticSearchAdmin- Parameters:
dropIfExists- if {true} remove an existing index
-
dropAndInitIndex
Description copied from interface:ElasticSearchAdminReinitialize an index. This will drop the existing index, recreate it with its settings and mapping, the index will be empty.- Specified by:
dropAndInitIndexin interfaceElasticSearchAdmin
-
dropAndInitRepositoryIndex
Description copied from interface:ElasticSearchAdminReinitialize the index of a repository. This will drop the existing index, recreate it with its settings and mapping, the index will be empty. When syncAlias is false then search alias is not updated with the new index, you need to explicitly callElasticSearchAdmin.syncSearchAndWriteAlias(String)- Specified by:
dropAndInitRepositoryIndexin interfaceElasticSearchAdmin
-
initRepositoryIndexWithAliases
Description copied from interface:ElasticSearchAdminCreates a new index for the repository applying the mapping and settings. Update the write alias to point to this new index. The search alias is updated to the new index only for the initial creation. Otherwise, there are two write indexes until an explicit call toElasticSearchAdmin.syncSearchAndWriteAlias(String).- Specified by:
initRepositoryIndexWithAliasesin interfaceElasticSearchAdmin
-
getRepositoryNames
Description copied from interface:ElasticSearchAdminList repository names that have Elasticsearch support.- Specified by:
getRepositoryNamesin interfaceElasticSearchAdmin
-
getIndexNameForRepository
Description copied from interface:ElasticSearchAdminGet the search index name associated with the repository name.- Specified by:
getIndexNameForRepositoryin interfaceElasticSearchAdmin
-
getRepositoryForIndex
Description copied from interface:ElasticSearchAdminGets the repository name associated with the index.- Specified by:
getRepositoryForIndexin interfaceElasticSearchAdmin
-
getIndexNamesForType
Description copied from interface:ElasticSearchAdminGet the index names with the given type.- Specified by:
getIndexNamesForTypein interfaceElasticSearchAdmin
-
getIndexNameForType
Description copied from interface:ElasticSearchAdminGet the first search index name with the given type.- Specified by:
getIndexNameForTypein interfaceElasticSearchAdmin
-
getWriteIndexName
Description copied from interface:ElasticSearchAdminReturns the index to use for any write operations.- Specified by:
getWriteIndexNamein interfaceElasticSearchAdmin
-
getSecondaryWriteIndexName
Description copied from interface:ElasticSearchAdminReturns the secondary write index used during re-indexing with aliases.- Specified by:
getSecondaryWriteIndexNamein interfaceElasticSearchAdmin- Returns:
- an index name or null if there is no re-indexing in progress.
-
syncSearchAndWriteAlias
Description copied from interface:ElasticSearchAdminMake sure that the search alias point to the same index as the write alias.- Specified by:
syncSearchAndWriteAliasin interfaceElasticSearchAdmin
-
getPendingWorkerCount
public long getPendingWorkerCount()Description copied from interface:ElasticSearchAdminReturns the number of indexing worker scheduled waiting to be executed.- Specified by:
getPendingWorkerCountin interfaceElasticSearchAdmin
-
getRunningWorkerCount
public long getRunningWorkerCount()Description copied from interface:ElasticSearchAdminReturns the number of indexing worker that are currently running.- Specified by:
getRunningWorkerCountin interfaceElasticSearchAdmin
-
getTotalCommandProcessed
public int getTotalCommandProcessed()Description copied from interface:ElasticSearchAdminReturns the total number of command processed by Elasticsearch for this Nuxeo instance. Useful for test assertion.- Specified by:
getTotalCommandProcessedin interfaceElasticSearchAdmin
-
isEmbedded
public boolean isEmbedded()Description copied from interface:ElasticSearchAdminReturns true if the Elasticsearch is embedded with Nuxeo, sharing the same JVM.- Specified by:
isEmbeddedin interfaceElasticSearchAdmin
-
useExternalVersion
public boolean useExternalVersion()Description copied from interface:ElasticSearchAdminWhen true use an external version for Elasticsearch document, this enable an optimistic concurrency control ensuring that an older version of a document never overwrites a newer version.- Specified by:
useExternalVersionin interfaceElasticSearchAdmin
-
isIndexingInProgress
public boolean isIndexingInProgress()Description copied from interface:ElasticSearchAdminReturns true if there are indexing activities scheduled or running.- Specified by:
isIndexingInProgressin interfaceElasticSearchAdmin
-
prepareWaitForIndexing
Description copied from interface:ElasticSearchAdminAFuturethat accepts callback on completion when all the indexing worker are done.- Specified by:
prepareWaitForIndexingin interfaceElasticSearchAdmin
-
initListenerThreadPool
protected void initListenerThreadPool() -
shutdownListenerThreadPool
protected void shutdownListenerThreadPool() -
refresh
public void refresh()Description copied from interface:ElasticSearchAdminRefresh all document indexes, immediately after the operation occurs, so that the updated document appears in search results immediately. There is no fsync thus doesn't guarantee durability.- Specified by:
refreshin interfaceElasticSearchAdmin
-
refreshRepositoryIndex
Description copied from interface:ElasticSearchAdminRefresh document index for the specific repository, immediately after the operation occurs, so that the updated document appears in search results immediately. There is no fsync thus doesn't guarantee durability.- Specified by:
refreshRepositoryIndexin interfaceElasticSearchAdmin
-
flush
public void flush()Description copied from interface:ElasticSearchAdminElasticsearch flush on all document indexes, triggers a lucene commit, empties the transaction log. Data is flushed to disk.- Specified by:
flushin interfaceElasticSearchAdmin
-
flushRepositoryIndex
Description copied from interface:ElasticSearchAdminElasticsearch flush on document index for a specific repository, triggers a lucene commit, empties the transaction log. Data is flushed to disk.- Specified by:
flushRepositoryIndexin interfaceElasticSearchAdmin
-
optimize
public void optimize()Description copied from interface:ElasticSearchAdminElasticsearch runElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String)on all document indexes,- Specified by:
optimizein interfaceElasticSearchAdmin
-
optimizeRepositoryIndex
Description copied from interface:ElasticSearchAdminElasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.- Specified by:
optimizeRepositoryIndexin interfaceElasticSearchAdmin
-
optimizeIndex
Description copied from interface:ElasticSearchAdminElasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.- Specified by:
optimizeIndexin interfaceElasticSearchAdmin
-
indexNonRecursive
Description copied from interface:ElasticSearchIndexingProcess theIndexingCommand.Send indexing command to Elasticsearch, if the command is synchronous the index is refreshed so the document is searchable immediately. Recursive indexing is not taken in account except for deletion. This is not a transactional operation, a rollback will not discard the executed commands.
- Specified by:
indexNonRecursivein interfaceElasticSearchIndexing
-
indexNonRecursive
Description copied from interface:ElasticSearchIndexingSame asElasticSearchIndexing.indexNonRecursive(org.nuxeo.elasticsearch.commands.IndexingCommand)but process the list command using a bulk request.- Specified by:
indexNonRecursivein interfaceElasticSearchIndexing
-
stackCommands
-
runIndexingWorker
Description copied from interface:ElasticSearchIndexingRun a worker to process theIndexingCommand.Asynchronous command schedules an indexing job and return.
Synchronous command execute an indexing job using a new Tx then refresh the index so the document is searchable immediately. if the command is also recursive the children are processed asynchronously.
If there is more than one cmd the elasticsearch request is done in bulk mode.
- Specified by:
runIndexingWorkerin interfaceElasticSearchIndexing
-
dispatchWork
Dispatch jobs between sync and async worker -
scheduleIndexingAsyncWorker
-
runIndexingSyncWorker
-
runReindexingWorker
Description copied from interface:ElasticSearchIndexingReindex documents matching the NXQL query, This is done in an asynchronous job. When syncAlias is true a call is made to sync the search alias with write alias once indexing is done.- Specified by:
runReindexingWorkerin interfaceElasticSearchIndexing
-
reindexRepository
Description copied from interface:ElasticSearchIndexingRecreate an index and run an async reindexing worker.- Specified by:
reindexRepositoryin interfaceElasticSearchIndexing
-
source
Description copied from interface:ElasticSearchIndexingReturns the JSON Elasticsearch source representation of a document.- Specified by:
sourcein interfaceElasticSearchIndexing- Throws:
IOException
-
query
Description copied from interface:ElasticSearchServiceReturns a document list using anNxQueryBuilder.- Specified by:
queryin interfaceElasticSearchService
-
queryAndAggregate
Description copied from interface:ElasticSearchServiceReturns documents and aggregates.- Specified by:
queryAndAggregatein interfaceElasticSearchService
-
scroll
Description copied from interface:ElasticSearchServicePerforms the initial search of a scrollable search request using anNxQueryBuilder.- Specified by:
scrollin interfaceElasticSearchServicekeepAlive- the search context lifetime- Returns:
- an
EsScrollResultincluding the search results and a scroll id, to be passed to the subsequent calls toElasticSearchService.scroll(EsScrollResult)
-
scroll
Description copied from interface:ElasticSearchServiceRetrieves the next batch of results of a scrollable search request for the givenEsScrollResult.- Specified by:
scrollin interfaceElasticSearchService- Returns:
- an
EsScrollResultincluding the search results and a scroll id, to be passed to the subsequent calls to {code scroll}.
-
clearScroll
Description copied from interface:ElasticSearchServiceClear scroll on ElasticSearch cluster for the givenEsScrollResult.- Specified by:
clearScrollin interfaceElasticSearchService
-
isReady
public boolean isReady() -
getHintByOperator
Description copied from interface:ElasticSearchAdminReturns the hint by the Elasticsearch operator name.- Specified by:
getHintByOperatorin interfaceElasticSearchAdmin
-