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
  • Field Details

    • LONG_TIMEOUT

      public static final String LONG_TIMEOUT
      See Also:
    • CREATE_INDEX_TIMEOUT

      public static final String CREATE_INDEX_TIMEOUT
      Deprecated.
      use LONG_TIMEOUT instead
      See Also:
    • lowLevelClient

      protected org.opensearch.client.RestClient lowLevelClient
    • client

      protected org.opensearch.client.RestHighLevelClient client
    • COMPAT_ES_OPTIONS

      protected org.opensearch.client.RequestOptions COMPAT_ES_OPTIONS
  • Constructor Details

    • ESRestClient

      public ESRestClient(org.opensearch.client.RestClient lowLevelRestClient, org.opensearch.client.RestHighLevelClient client)
  • Method Details

    • waitForYellowStatus

      public boolean waitForYellowStatus(String[] indexNames, int timeoutSecond)
      Specified by:
      waitForYellowStatus in interface ESClient
    • getIndexesAsString

      protected String getIndexesAsString(String[] indexNames)
    • getHealthStatus

      public org.opensearch.cluster.health.ClusterHealthStatus getHealthStatus(String[] indexNames)
      Specified by:
      getHealthStatus in interface ESClient
    • refresh

      public void refresh(String indexName)
      Specified by:
      refresh in interface ESClient
    • flush

      public void flush(String indexName)
      Specified by:
      flush in interface ESClient
    • optimize

      public void optimize(String indexName)
      Specified by:
      optimize in interface ESClient
    • indexExists

      public boolean indexExists(String indexName)
      Specified by:
      indexExists in interface ESClient
    • mappingExists

      public boolean mappingExists(String indexName, String type)
      Specified by:
      mappingExists in interface ESClient
    • deleteIndex

      public void deleteIndex(String indexName, int timeoutSecond)
      Specified by:
      deleteIndex in interface ESClient
    • createIndex

      public void createIndex(String indexName, String jsonSettings)
      Specified by:
      createIndex in interface ESClient
    • createMapping

      public void createMapping(String indexName, String type, String jsonMapping)
      Specified by:
      createMapping in interface ESClient
    • getMapping

      public String getMapping(String indexName)
      Description copied from interface: ESClient
      Returns the mapping from elastic, exposed for testing purposes
      Specified by:
      getMapping in interface ESClient
    • performRequest

      protected org.opensearch.client.Response performRequest(org.opensearch.client.Request request)
    • performRequestWithTracing

      public org.opensearch.client.Response performRequestWithTracing(org.opensearch.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 interface ESClient
    • getNodesStats

      public String getNodesStats()
      Specified by:
      getNodesStats in interface ESClient
    • aliasExists

      public boolean aliasExists(String aliasName)
      Specified by:
      aliasExists in interface ESClient
    • 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 interface ESClient
    • updateAlias

      public void updateAlias(String aliasName, String indexName)
      Specified by:
      updateAlias in interface ESClient
    • deleteAlias

      protected void deleteAlias(String aliasName)
    • createAlias

      protected void createAlias(String aliasName, String indexName)
    • bulk

      public org.opensearch.action.bulk.BulkResponse bulk(org.opensearch.action.bulk.BulkRequest request)
      Specified by:
      bulk in interface ESClient
    • doBulk

      protected org.opensearch.action.bulk.BulkResponse doBulk(org.opensearch.action.bulk.BulkRequest request) throws ESRestClient.TooManyRequestsRetryableException
      Throws:
      ESRestClient.TooManyRequestsRetryableException
    • delete

      public org.opensearch.action.delete.DeleteResponse delete(org.opensearch.action.delete.DeleteRequest request)
      Specified by:
      delete in interface ESClient
    • doDelete

      protected org.opensearch.action.delete.DeleteResponse doDelete(org.opensearch.action.delete.DeleteRequest request) throws ESRestClient.TooManyRequestsRetryableException
      Throws:
      ESRestClient.TooManyRequestsRetryableException
    • search

      public org.opensearch.action.search.SearchResponse search(org.opensearch.action.search.SearchRequest request)
      Specified by:
      search in interface ESClient
    • searchScroll

      public org.opensearch.action.search.SearchResponse searchScroll(org.opensearch.action.search.SearchScrollRequest request)
      Specified by:
      searchScroll in interface ESClient
    • get

      public org.opensearch.action.get.GetResponse get(org.opensearch.action.get.GetRequest request)
      Specified by:
      get in interface ESClient
    • index

      public org.opensearch.action.index.IndexResponse index(org.opensearch.action.index.IndexRequest request)
      Description copied from interface: ESClient
      Performs the indexing request.
      Specified by:
      index in interface ESClient
    • doIndex

      protected org.opensearch.action.index.IndexResponse doIndex(org.opensearch.action.index.IndexRequest request) throws ESRestClient.TooManyRequestsRetryableException
      Throws:
      ESRestClient.TooManyRequestsRetryableException
    • getScopedSpan

      protected io.opencensus.common.Scope getScopedSpan(String name, String request)
    • clearScroll

      public org.opensearch.action.search.ClearScrollResponse clearScroll(org.opensearch.action.search.ClearScrollRequest request)
      Specified by:
      clearScroll in interface ESClient
    • bulkProcessorBuilder

      public org.opensearch.action.bulk.BulkProcessor.Builder bulkProcessorBuilder(org.opensearch.action.bulk.BulkProcessor.Listener bulkListener)
      Description copied from interface: ESClient
      Creates an elasticsearch BulkProcessor builder.
      Specified by:
      bulkProcessorBuilder in interface ESClient
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable