public class ElasticSearchComponent extends DefaultComponent implements ElasticSearchAdmin, ElasticSearchIndexing, ElasticSearchService
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ElasticSearchComponent.NamedThreadFactory |
| Modifier and Type | Field and Description |
|---|---|
protected ElasticSearchClientConfig |
clientConfig |
protected ElasticSearchEmbeddedServerConfig |
embeddedServerConfig |
protected static String |
EP_CLIENT_INIT |
protected static String |
EP_DOC_WRITER |
protected static String |
EP_EMBEDDED_SERVER |
protected static String |
EP_INDEX |
protected ElasticSearchAdminImpl |
esa |
protected ElasticSearchIndexingImpl |
esi |
protected ElasticSearchServiceImpl |
ess |
protected Map<String,ElasticSearchIndexConfig> |
indexConfig |
protected JsonESDocumentWriter |
jsonESDocumentWriter |
protected static org.apache.commons.logging.Log |
log |
protected static long |
REINDEX_TIMEOUT |
protected AtomicInteger |
runIndexingWorkerCount |
protected List<IndexingCommand> |
stackedCommands |
protected com.google.common.util.concurrent.ListeningExecutorService |
waiterExecutorService |
lastModified| Constructor and Description |
|---|
ElasticSearchComponent() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearScroll(EsScrollResult scrollResult)
Clear scroll on ElasticSearch cluster for the given
EsScrollResult. |
protected void |
dispatchWork(List<IndexingCommand> cmds)
Dispatch jobs between sync and async worker
|
void |
dropAndInitIndex(String indexName)
Reinitialize an index.
|
void |
dropAndInitRepositoryIndex(String repositoryName,
boolean syncAlias)
Reinitialize the index of a repository.
|
void |
flush()
Elasticsearch flush on all document indexes, triggers a lucene commit, empties the transaction log.
|
void |
flushRepositoryIndex(String repositoryName)
Elasticsearch flush on document index for a specific repository, triggers a lucene commit, empties the
transaction log.
|
int |
getApplicationStartedOrder()
The component notification order for
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext). |
ESClient |
getClient()
Retrieves the
Client that can be used to access Elasticsearch API |
String |
getIndexNameForRepository(String repositoryName)
Get the search index name associated with the repository name.
|
String |
getIndexNameForType(String type)
Get the first search index name with the given type.
|
List<String> |
getIndexNamesForType(String type)
Get the index names with the given type.
|
long |
getPendingWorkerCount()
Returns the number of indexing worker scheduled waiting to be executed.
|
String |
getRepositoryForIndex(String indexName)
Gets the repository name associated with the index.
|
List<String> |
getRepositoryNames()
List repository names that have Elasticsearch support.
|
long |
getRunningWorkerCount()
Returns the number of indexing worker that are currently running.
|
int |
getTotalCommandProcessed()
Returns the total number of command processed by Elasticsearch for this Nuxeo instance.
|
String |
getWriteIndexName(String searchIndexName)
Returns the index to use for any write operations.
|
void |
indexNonRecursive(IndexingCommand cmd)
Process the
IndexingCommand. |
void |
indexNonRecursive(List<IndexingCommand> cmds)
Same as
ElasticSearchIndexing.indexNonRecursive(org.nuxeo.elasticsearch.commands.IndexingCommand) but
process the list command using a bulk request. |
void |
initIndexes(boolean dropIfExists)
Initialize Elasticsearch indexes.
|
protected void |
initListenerThreadPool() |
protected boolean |
isElasticsearchEnabled() |
boolean |
isEmbedded()
Returns true if the Elasticsearch is embedded with Nuxeo, sharing the same JVM.
|
boolean |
isIndexingInProgress()
Returns true if there are indexing activities scheduled or running.
|
protected boolean |
isReady() |
void |
optimize()
Elasticsearch run
ElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String) on all document indexes, |
void |
optimizeIndex(String indexName)
Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially
be a very heavy operation.
|
void |
optimizeRepositoryIndex(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> |
prepareWaitForIndexing()
A
Future that accepts callback on completion when all the indexing worker are done. |
DocumentModelList |
query(CoreSession session,
org.elasticsearch.index.query.QueryBuilder queryBuilder,
int limit,
int offset,
SortInfo... sortInfos)
Deprecated.
|
DocumentModelList |
query(CoreSession session,
String nxql,
int limit,
int offset,
SortInfo... sortInfos)
Deprecated.
|
DocumentModelList |
query(NxQueryBuilder queryBuilder)
Returns a document list using an
NxQueryBuilder. |
EsResult |
queryAndAggregate(NxQueryBuilder queryBuilder)
Returns documents and aggregates.
|
void |
refresh()
Refresh all document indexes, immediately after the operation occurs, so that the updated document appears in
search results immediately.
|
void |
refreshRepositoryIndex(String repositoryName)
Refresh document index for the specific repository, immediately after the operation occurs, so that the updated
document appears in search results immediately.
|
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
reindexOnStartup() |
void |
reindexRepository(String repositoryName)
Recreate an index and run an async reindexing worker.
|
protected void |
runIndexingSyncWorker(Map<String,List<IndexingCommand>> syncCommands) |
void |
runIndexingWorker(List<IndexingCommand> cmds)
Run a worker to process the
IndexingCommand. |
void |
runReindexingWorker(String repositoryName,
String nxql,
boolean syncAlias)
Reindex documents matching the NXQL query, This is done in an asynchronous job.
|
protected void |
scheduleIndexingAsyncWorker(Map<String,List<IndexingCommand>> asyncCommands) |
EsScrollResult |
scroll(EsScrollResult scrollResult)
Retrieves the next batch of results of a scrollable search request for the given
EsScrollResult. |
EsScrollResult |
scroll(NxQueryBuilder queryBuilder,
long keepAlive)
Performs the initial search of a scrollable search request using an
NxQueryBuilder. |
protected void |
shutdownListenerThreadPool() |
protected void |
stackCommands(List<IndexingCommand> cmds) |
void |
start(ComponentContext context)
Start the component.
|
void |
stop(ComponentContext context)
Stop the component.
|
void |
syncSearchAndWriteAlias(String searchIndexName)
Make sure that the search alias point to the same index as the write alias.
|
boolean |
useExternalVersion()
When 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.
|
activate, deactivate, getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterContribution, unregisterExtensionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdropAndInitRepositoryIndexrunReindexingWorkerapplicationStartedprotected static final org.apache.commons.logging.Log log
protected static final String EP_EMBEDDED_SERVER
protected static final String EP_CLIENT_INIT
protected static final String EP_INDEX
protected static final String EP_DOC_WRITER
protected static final long REINDEX_TIMEOUT
protected final List<IndexingCommand> stackedCommands
protected final Map<String,ElasticSearchIndexConfig> indexConfig
protected final AtomicInteger runIndexingWorkerCount
protected ElasticSearchEmbeddedServerConfig embeddedServerConfig
protected ElasticSearchClientConfig clientConfig
protected ElasticSearchAdminImpl esa
protected ElasticSearchIndexingImpl esi
protected ElasticSearchServiceImpl ess
protected JsonESDocumentWriter jsonESDocumentWriter
protected com.google.common.util.concurrent.ListeningExecutorService waiterExecutorService
public ElasticSearchComponent()
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution in class DefaultComponentpublic void start(ComponentContext context)
Componentstart in interface Componentstart in class DefaultComponentpublic void stop(ComponentContext context)
Componentstop in interface Componentstop in class DefaultComponentprotected void reindexOnStartup()
protected boolean isElasticsearchEnabled()
public int getApplicationStartedOrder()
ComponentComponent.applicationStarted(org.nuxeo.runtime.model.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.
getApplicationStartedOrder in interface Componentpublic ESClient getClient()
ElasticSearchAdminClient that can be used to access Elasticsearch APIgetClient in interface ElasticSearchAdminpublic void initIndexes(boolean dropIfExists)
ElasticSearchAdmininitIndexes in interface ElasticSearchAdmindropIfExists - if {true} remove an existing indexpublic void dropAndInitIndex(String indexName)
ElasticSearchAdmindropAndInitIndex in interface ElasticSearchAdminpublic void dropAndInitRepositoryIndex(String repositoryName, boolean syncAlias)
ElasticSearchAdminElasticSearchAdmin.syncSearchAndWriteAlias(String)dropAndInitRepositoryIndex in interface ElasticSearchAdminpublic List<String> getRepositoryNames()
ElasticSearchAdmingetRepositoryNames in interface ElasticSearchAdminpublic String getIndexNameForRepository(String repositoryName)
ElasticSearchAdmingetIndexNameForRepository in interface ElasticSearchAdminpublic String getRepositoryForIndex(String indexName)
ElasticSearchAdmingetRepositoryForIndex in interface ElasticSearchAdminpublic List<String> getIndexNamesForType(String type)
ElasticSearchAdmingetIndexNamesForType in interface ElasticSearchAdminpublic String getIndexNameForType(String type)
ElasticSearchAdmingetIndexNameForType in interface ElasticSearchAdminpublic String getWriteIndexName(String searchIndexName)
ElasticSearchAdmingetWriteIndexName in interface ElasticSearchAdminpublic void syncSearchAndWriteAlias(String searchIndexName)
ElasticSearchAdminsyncSearchAndWriteAlias in interface ElasticSearchAdminpublic long getPendingWorkerCount()
ElasticSearchAdmingetPendingWorkerCount in interface ElasticSearchAdminpublic long getRunningWorkerCount()
ElasticSearchAdmingetRunningWorkerCount in interface ElasticSearchAdminpublic int getTotalCommandProcessed()
ElasticSearchAdmingetTotalCommandProcessed in interface ElasticSearchAdminpublic boolean isEmbedded()
ElasticSearchAdminisEmbedded in interface ElasticSearchAdminpublic boolean useExternalVersion()
ElasticSearchAdminuseExternalVersion in interface ElasticSearchAdminpublic boolean isIndexingInProgress()
ElasticSearchAdminisIndexingInProgress in interface ElasticSearchAdminpublic com.google.common.util.concurrent.ListenableFuture<Boolean> prepareWaitForIndexing()
ElasticSearchAdminFuture that accepts callback on completion when all the indexing worker are done.prepareWaitForIndexing in interface ElasticSearchAdminprotected void initListenerThreadPool()
protected void shutdownListenerThreadPool()
public void refresh()
ElasticSearchAdminrefresh in interface ElasticSearchAdminpublic void refreshRepositoryIndex(String repositoryName)
ElasticSearchAdminrefreshRepositoryIndex in interface ElasticSearchAdminpublic void flush()
ElasticSearchAdminflush in interface ElasticSearchAdminpublic void flushRepositoryIndex(String repositoryName)
ElasticSearchAdminflushRepositoryIndex in interface ElasticSearchAdminpublic void optimize()
ElasticSearchAdminElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String) on all document indexes,optimize in interface ElasticSearchAdminpublic void optimizeRepositoryIndex(String repositoryName)
ElasticSearchAdminoptimizeRepositoryIndex in interface ElasticSearchAdminpublic void optimizeIndex(String indexName)
ElasticSearchAdminoptimizeIndex in interface ElasticSearchAdminpublic void indexNonRecursive(IndexingCommand cmd)
ElasticSearchIndexingIndexingCommand.
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.
indexNonRecursive in interface ElasticSearchIndexingpublic void indexNonRecursive(List<IndexingCommand> cmds)
ElasticSearchIndexingElasticSearchIndexing.indexNonRecursive(org.nuxeo.elasticsearch.commands.IndexingCommand) but
process the list command using a bulk request.
indexNonRecursive in interface ElasticSearchIndexingprotected void stackCommands(List<IndexingCommand> cmds)
public void runIndexingWorker(List<IndexingCommand> cmds)
ElasticSearchIndexingIndexingCommand.
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.
runIndexingWorker in interface ElasticSearchIndexingprotected void dispatchWork(List<IndexingCommand> cmds)
protected void scheduleIndexingAsyncWorker(Map<String,List<IndexingCommand>> asyncCommands)
protected void runIndexingSyncWorker(Map<String,List<IndexingCommand>> syncCommands)
public void runReindexingWorker(String repositoryName, String nxql, boolean syncAlias)
ElasticSearchIndexingrunReindexingWorker in interface ElasticSearchIndexingpublic void reindexRepository(String repositoryName)
ElasticSearchIndexingreindexRepository in interface ElasticSearchIndexingpublic DocumentModelList query(NxQueryBuilder queryBuilder)
ElasticSearchServiceNxQueryBuilder.query in interface ElasticSearchServicepublic EsResult queryAndAggregate(NxQueryBuilder queryBuilder)
ElasticSearchServicequeryAndAggregate in interface ElasticSearchServicepublic EsScrollResult scroll(NxQueryBuilder queryBuilder, long keepAlive)
ElasticSearchServiceNxQueryBuilder.scroll in interface ElasticSearchServicekeepAlive - the search context lifetimeEsScrollResult including the search results and a scroll id, to be passed to the subsequent
calls to ElasticSearchService.scroll(EsScrollResult)public EsScrollResult scroll(EsScrollResult scrollResult)
ElasticSearchServiceEsScrollResult.scroll in interface ElasticSearchServiceEsScrollResult including the search results and a scroll id, to be passed to the subsequent
calls to {code scroll}.public void clearScroll(EsScrollResult scrollResult)
ElasticSearchServiceEsScrollResult.clearScroll in interface ElasticSearchService@Deprecated public DocumentModelList query(CoreSession session, String nxql, int limit, int offset, SortInfo... sortInfos)
ElasticSearchServicequery in interface ElasticSearchService@Deprecated public DocumentModelList query(CoreSession session, org.elasticsearch.index.query.QueryBuilder queryBuilder, int limit, int offset, SortInfo... sortInfos)
ElasticSearchServiceQueryBuilder. Fetch documents from the VCS repository.query in interface ElasticSearchServiceprotected boolean isReady()
Copyright © 2018 Nuxeo. All rights reserved.