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 class
ESRestClient.TooManyRequestsRetryableException
Exception when Elastic is overloaded by indexing requests.
-
Field Summary
Fields Modifier and Type Field Description protected org.elasticsearch.client.RestHighLevelClient
client
protected org.elasticsearch.client.RequestOptions
COMPAT_ES_OPTIONS
static String
CREATE_INDEX_TIMEOUT
Deprecated.useLONG_TIMEOUT
insteadstatic String
LONG_TIMEOUT
protected org.elasticsearch.client.RestClient
lowLevelClient
-
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 boolean
aliasExists(String aliasName)
org.elasticsearch.action.bulk.BulkResponse
bulk(org.elasticsearch.action.bulk.BulkRequest request)
org.elasticsearch.action.bulk.BulkProcessor.Builder
bulkProcessorBuilder(org.elasticsearch.action.bulk.BulkProcessor.Listener bulkListener)
Creates an elasticsearch BulkProcessor builder.org.elasticsearch.action.search.ClearScrollResponse
clearScroll(org.elasticsearch.action.search.ClearScrollRequest request)
void
close()
protected void
createAlias(String aliasName, String indexName)
void
createIndex(String indexName, String jsonSettings)
void
createMapping(String indexName, String type, String jsonMapping)
org.elasticsearch.action.delete.DeleteResponse
delete(org.elasticsearch.action.delete.DeleteRequest request)
protected void
deleteAlias(String aliasName)
void
deleteIndex(String indexName, int timeoutSecond)
protected org.elasticsearch.action.bulk.BulkResponse
doBulk(org.elasticsearch.action.bulk.BulkRequest request)
protected org.elasticsearch.action.delete.DeleteResponse
doDelete(org.elasticsearch.action.delete.DeleteRequest request)
protected org.elasticsearch.action.index.IndexResponse
doIndex(org.elasticsearch.action.index.IndexRequest request)
void
flush(String indexName)
org.elasticsearch.action.get.GetResponse
get(org.elasticsearch.action.get.GetRequest request)
String
getFirstIndexForAlias(String aliasName)
Returns the name of the index referenced by the alias.org.elasticsearch.cluster.health.ClusterHealthStatus
getHealthStatus(String[] indexNames)
protected String
getIndexesAsString(String[] indexNames)
String
getMapping(String indexName)
Returns the mapping from elastic, exposed for testing purposesString
getNodesInfo()
String
getNodesStats()
protected io.opencensus.common.Scope
getScopedSpan(String name, String request)
org.elasticsearch.action.index.IndexResponse
index(org.elasticsearch.action.index.IndexRequest request)
Performs the indexing request.boolean
indexExists(String indexName)
boolean
mappingExists(String indexName, String type)
void
optimize(String indexName)
protected org.elasticsearch.client.Response
performRequest(org.elasticsearch.client.Request request)
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.void
refresh(String indexName)
org.elasticsearch.action.search.SearchResponse
search(org.elasticsearch.action.search.SearchRequest request)
org.elasticsearch.action.search.SearchResponse
searchScroll(org.elasticsearch.action.search.SearchScrollRequest request)
void
updateAlias(String aliasName, String indexName)
boolean
waitForYellowStatus(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_TIMEOUT
instead- 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:
waitForYellowStatus
in interfaceESClient
-
getHealthStatus
public org.elasticsearch.cluster.health.ClusterHealthStatus getHealthStatus(String[] indexNames)
- Specified by:
getHealthStatus
in interfaceESClient
-
indexExists
public boolean indexExists(String indexName)
- Specified by:
indexExists
in interfaceESClient
-
mappingExists
public boolean mappingExists(String indexName, String type)
- Specified by:
mappingExists
in interfaceESClient
-
deleteIndex
public void deleteIndex(String indexName, int timeoutSecond)
- Specified by:
deleteIndex
in interfaceESClient
-
createIndex
public void createIndex(String indexName, String jsonSettings)
- Specified by:
createIndex
in interfaceESClient
-
createMapping
public void createMapping(String indexName, String type, String jsonMapping)
- Specified by:
createMapping
in interfaceESClient
-
getMapping
public String getMapping(String indexName)
Description copied from interface:ESClient
Returns the mapping from elastic, exposed for testing purposes- Specified by:
getMapping
in 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:
getNodesInfo
in interfaceESClient
-
getNodesStats
public String getNodesStats()
- Specified by:
getNodesStats
in interfaceESClient
-
aliasExists
public boolean aliasExists(String aliasName)
- Specified by:
aliasExists
in interfaceESClient
-
getFirstIndexForAlias
public String getFirstIndexForAlias(String aliasName)
Description copied from interface:ESClient
Returns the name of the index referenced by the alias. Returns null if the alias does not exists.- Specified by:
getFirstIndexForAlias
in interfaceESClient
-
updateAlias
public void updateAlias(String aliasName, String indexName)
- Specified by:
updateAlias
in 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:
searchScroll
in 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:ESClient
Performs 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:
clearScroll
in interfaceESClient
-
bulkProcessorBuilder
public org.elasticsearch.action.bulk.BulkProcessor.Builder bulkProcessorBuilder(org.elasticsearch.action.bulk.BulkProcessor.Listener bulkListener)
Description copied from interface:ESClient
Creates an elasticsearch BulkProcessor builder.- Specified by:
bulkProcessorBuilder
in interfaceESClient
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-