Class OpenSearchRestClient

java.lang.Object
org.nuxeo.runtime.opensearch1.client.OpenSearchRestClient
All Implemented Interfaces:
AutoCloseable, OpenSearchClient

public class OpenSearchRestClient extends Object implements OpenSearchClient
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:
    • id

      protected final String id
    • client

      protected final org.opensearch.client.RestHighLevelClient client
    • COMPAT_ES_OPTIONS

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

    • OpenSearchRestClient

      public OpenSearchRestClient(String id, org.opensearch.client.RestHighLevelClient client)
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface OpenSearchClient
      Returns:
      The client id
    • isReady

      public boolean isReady()
      Specified by:
      isReady in interface OpenSearchClient
      Returns:
      Whether the targeted OpenSearch is ready or not (its status is at least ClusterHealthStatus.YELLOW
    • waitForYellowStatus

      public boolean waitForYellowStatus(String[] indexNames, Duration timeout)
      Specified by:
      waitForYellowStatus in interface OpenSearchClient
    • getIndexesAsString

      protected String getIndexesAsString(String[] indexNames)
    • refresh

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

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

      public void optimize(String indexName)
      Specified by:
      optimize in interface OpenSearchClient
    • createIndex

      public void createIndex(String indexName, String jsonSettings)
      Specified by:
      createIndex in interface OpenSearchClient
    • indexExists

      public boolean indexExists(String indexName)
      Specified by:
      indexExists in interface OpenSearchClient
    • dropIndex

      public void dropIndex(String indexName, Duration timeout)
      Specified by:
      dropIndex in interface OpenSearchClient
    • createMapping

      public void createMapping(String indexName, String jsonMapping)
      Specified by:
      createMapping in interface OpenSearchClient
    • mappingExists

      public boolean mappingExists(String indexName)
      Specified by:
      mappingExists in interface OpenSearchClient
    • getMapping

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

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

      public boolean aliasExists(String aliasName)
      Specified by:
      aliasExists in interface OpenSearchClient
    • getFirstIndexForAlias

      public String getFirstIndexForAlias(String aliasName)
      Description copied from interface: OpenSearchClient
      Returns the name of the index referenced by the alias. Returns null if the alias does not exists.
      Specified by:
      getFirstIndexForAlias in interface OpenSearchClient
    • updateAlias

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

      protected void deleteAlias(String aliasName)
    • performRequestWithTracing

      @Deprecated(forRemoval=true) public org.opensearch.client.Response performRequestWithTracing(org.opensearch.client.Request request)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Performs an OpenSearch request using the low level client, exposed since 11.5 for internal use only.
    • index

      public org.opensearch.action.index.IndexResponse index(org.opensearch.action.index.IndexRequest request)
      Specified by:
      index in interface OpenSearchClient
    • doIndex

      protected org.opensearch.action.index.IndexResponse doIndex(org.opensearch.action.index.IndexRequest request) throws RetryableException
      Throws:
      RetryableException
    • bulk

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

      protected org.opensearch.action.bulk.BulkResponse doBulk(org.opensearch.action.bulk.BulkRequest request) throws RetryableException
      Throws:
      RetryableException
    • get

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

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

      public org.opensearch.action.search.SearchResponse scroll(org.opensearch.action.search.SearchScrollRequest request)
      Specified by:
      scroll in interface OpenSearchClient
    • clearScroll

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

      protected <I extends org.opensearch.action.ActionRequest, O extends org.opensearch.action.ActionResponse> O performRequestWithTracing(ThrowableBiFunction<I,org.opensearch.client.RequestOptions,O,IOException> runner, I request, String spanName)
    • getScopedSpan

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

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