Package org.nuxeo.elasticsearch.client
Class ESRestClient
- java.lang.Object
-
- org.nuxeo.elasticsearch.client.ESRestClient
-
- All Implemented Interfaces:
AutoCloseable,ESClient
public class ESRestClient extends Object implements ESClient
- Since:
- 9.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classESRestClient.TooManyRequestsRetryableExceptionException when Elastic is overloaded by indexing requests.
-
Field Summary
Fields Modifier and Type Field Description protected org.elasticsearch.client.RestHighLevelClientclientprotected org.elasticsearch.client.RequestOptionsCOMPAT_ES_OPTIONSstatic StringCREATE_INDEX_TIMEOUTDeprecated.useLONG_TIMEOUTinsteadstatic StringLONG_TIMEOUTprotected org.elasticsearch.client.RestClientlowLevelClient
-
Constructor Summary
Constructors Constructor Description ESRestClient(org.elasticsearch.client.RestClient lowLevelRestClient, org.elasticsearch.client.RestHighLevelClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaliasExists(String aliasName)org.elasticsearch.action.bulk.BulkResponsebulk(org.elasticsearch.action.bulk.BulkRequest request)org.elasticsearch.action.bulk.BulkProcessor.BuilderbulkProcessorBuilder(org.elasticsearch.action.bulk.BulkProcessor.Listener bulkListener)Creates an elasticsearch BulkProcessor builder.org.elasticsearch.action.search.ClearScrollResponseclearScroll(org.elasticsearch.action.search.ClearScrollRequest request)voidclose()protected voidcreateAlias(String aliasName, String indexName)voidcreateIndex(String indexName, String jsonSettings)voidcreateMapping(String indexName, String type, String jsonMapping)org.elasticsearch.action.delete.DeleteResponsedelete(org.elasticsearch.action.delete.DeleteRequest request)protected voiddeleteAlias(String aliasName)voiddeleteIndex(String indexName, int timeoutSecond)protected org.elasticsearch.action.bulk.BulkResponsedoBulk(org.elasticsearch.action.bulk.BulkRequest request)protected org.elasticsearch.action.delete.DeleteResponsedoDelete(org.elasticsearch.action.delete.DeleteRequest request)protected org.elasticsearch.action.index.IndexResponsedoIndex(org.elasticsearch.action.index.IndexRequest request)voidflush(String indexName)org.elasticsearch.action.get.GetResponseget(org.elasticsearch.action.get.GetRequest request)StringgetFirstIndexForAlias(String aliasName)Returns the name of the index referenced by the alias.org.elasticsearch.cluster.health.ClusterHealthStatusgetHealthStatus(String[] indexNames)protected StringgetIndexesAsString(String[] indexNames)StringgetMapping(String indexName)Returns the mapping from elastic, exposed for testing purposesStringgetNodesInfo()StringgetNodesStats()protected io.opencensus.common.ScopegetScopedSpan(String name, String request)org.elasticsearch.action.index.IndexResponseindex(org.elasticsearch.action.index.IndexRequest request)Performs the indexing request.booleanindexExists(String indexName)booleanmappingExists(String indexName, String type)voidoptimize(String indexName)protected org.elasticsearch.client.ResponseperformRequest(org.elasticsearch.client.Request request)org.elasticsearch.client.ResponseperformRequestWithTracing(org.elasticsearch.client.Request request)Performs an Elastic request using the low level client, exposed since 11.5 for internal use only.voidrefresh(String indexName)org.elasticsearch.action.search.SearchResponsesearch(org.elasticsearch.action.search.SearchRequest request)org.elasticsearch.action.search.SearchResponsesearchScroll(org.elasticsearch.action.search.SearchScrollRequest request)voidupdateAlias(String aliasName, String indexName)booleanwaitForYellowStatus(String[] indexNames, int timeoutSecond)
-
-
-
Field Detail
-
LONG_TIMEOUT
public static final String LONG_TIMEOUT
- See Also:
- Constant Field Values
-
CREATE_INDEX_TIMEOUT
public static final String CREATE_INDEX_TIMEOUT
Deprecated.useLONG_TIMEOUTinstead- See Also:
- Constant Field Values
-
lowLevelClient
protected org.elasticsearch.client.RestClient lowLevelClient
-
client
protected org.elasticsearch.client.RestHighLevelClient client
-
COMPAT_ES_OPTIONS
protected org.elasticsearch.client.RequestOptions COMPAT_ES_OPTIONS
-
-
Method Detail
-
waitForYellowStatus
public boolean waitForYellowStatus(String[] indexNames, int timeoutSecond)
- Specified by:
waitForYellowStatusin interfaceESClient
-
getHealthStatus
public org.elasticsearch.cluster.health.ClusterHealthStatus getHealthStatus(String[] indexNames)
- Specified by:
getHealthStatusin interfaceESClient
-
indexExists
public boolean indexExists(String indexName)
- Specified by:
indexExistsin interfaceESClient
-
mappingExists
public boolean mappingExists(String indexName, String type)
- Specified by:
mappingExistsin interfaceESClient
-
deleteIndex
public void deleteIndex(String indexName, int timeoutSecond)
- Specified by:
deleteIndexin interfaceESClient
-
createIndex
public void createIndex(String indexName, String jsonSettings)
- Specified by:
createIndexin interfaceESClient
-
createMapping
public void createMapping(String indexName, String type, String jsonMapping)
- Specified by:
createMappingin interfaceESClient
-
getMapping
public String getMapping(String indexName)
Description copied from interface:ESClientReturns the mapping from elastic, exposed for testing purposes- Specified by:
getMappingin interfaceESClient
-
performRequest
protected org.elasticsearch.client.Response performRequest(org.elasticsearch.client.Request request)
-
performRequestWithTracing
public org.elasticsearch.client.Response performRequestWithTracing(org.elasticsearch.client.Request request)
Performs an Elastic request using the low level client, exposed since 11.5 for internal use only.
-
getNodesInfo
public String getNodesInfo()
- Specified by:
getNodesInfoin interfaceESClient
-
getNodesStats
public String getNodesStats()
- Specified by:
getNodesStatsin interfaceESClient
-
aliasExists
public boolean aliasExists(String aliasName)
- Specified by:
aliasExistsin interfaceESClient
-
getFirstIndexForAlias
public String getFirstIndexForAlias(String aliasName)
Description copied from interface:ESClientReturns the name of the index referenced by the alias. Returns null if the alias does not exists.- Specified by:
getFirstIndexForAliasin interfaceESClient
-
updateAlias
public void updateAlias(String aliasName, String indexName)
- Specified by:
updateAliasin interfaceESClient
-
deleteAlias
protected void deleteAlias(String aliasName)
-
bulk
public org.elasticsearch.action.bulk.BulkResponse bulk(org.elasticsearch.action.bulk.BulkRequest request)
-
doBulk
protected org.elasticsearch.action.bulk.BulkResponse doBulk(org.elasticsearch.action.bulk.BulkRequest request) throws ESRestClient.TooManyRequestsRetryableException
-
delete
public org.elasticsearch.action.delete.DeleteResponse delete(org.elasticsearch.action.delete.DeleteRequest request)
-
doDelete
protected org.elasticsearch.action.delete.DeleteResponse doDelete(org.elasticsearch.action.delete.DeleteRequest request) throws ESRestClient.TooManyRequestsRetryableException
-
search
public org.elasticsearch.action.search.SearchResponse search(org.elasticsearch.action.search.SearchRequest request)
-
searchScroll
public org.elasticsearch.action.search.SearchResponse searchScroll(org.elasticsearch.action.search.SearchScrollRequest request)
- Specified by:
searchScrollin interfaceESClient
-
get
public org.elasticsearch.action.get.GetResponse get(org.elasticsearch.action.get.GetRequest request)
-
index
public org.elasticsearch.action.index.IndexResponse index(org.elasticsearch.action.index.IndexRequest request)
Description copied from interface:ESClientPerforms the indexing request.
-
doIndex
protected org.elasticsearch.action.index.IndexResponse doIndex(org.elasticsearch.action.index.IndexRequest request) throws ESRestClient.TooManyRequestsRetryableException
-
clearScroll
public org.elasticsearch.action.search.ClearScrollResponse clearScroll(org.elasticsearch.action.search.ClearScrollRequest request)
- Specified by:
clearScrollin interfaceESClient
-
bulkProcessorBuilder
public org.elasticsearch.action.bulk.BulkProcessor.Builder bulkProcessorBuilder(org.elasticsearch.action.bulk.BulkProcessor.Listener bulkListener)
Description copied from interface:ESClientCreates an elasticsearch BulkProcessor builder.- Specified by:
bulkProcessorBuilderin interfaceESClient
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-