Class OpenSearchTemplate

java.lang.Object
org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
org.opensearch.data.client.osc.OpenSearchTemplate
All Implemented Interfaces:
OpenSearchOperations, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.data.elasticsearch.core.DocumentOperations, org.springframework.data.elasticsearch.core.ElasticsearchOperations, org.springframework.data.elasticsearch.core.script.ScriptOperations, org.springframework.data.elasticsearch.core.SearchOperations

public class OpenSearchTemplate extends org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate implements OpenSearchOperations
Implementation of ElasticsearchOperations using the new OpenSearch client.
Since:
4.4
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Callback interface to be used with execute(OpenSearchTemplate.ClientCallback) for operating directly on the OpenSearchClient.

    Nested classes/interfaces inherited from class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate

    org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.DocumentCallback<T extends Object>, org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.ReadDocumentCallback<T extends Object>, org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.ReadSearchDocumentResponseCallback<T extends Object>, org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.ReadSearchScrollDocumentResponseCallback<T extends Object>, org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate.SearchDocumentResponseCallback<T extends Object>

    Nested classes/interfaces inherited from interface org.opensearch.data.core.OpenSearchOperations

    OpenSearchOperations.PitInfo
  • Field Summary

    Fields inherited from class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate

    elasticsearchConverter, entityCallbacks, entityOperations, refreshPolicy, routingResolver
  • Constructor Summary

    Constructors
    Constructor
    Description
    OpenSearchTemplate(org.opensearch.client.opensearch.OpenSearchClient client)
     
    OpenSearchTemplate(org.opensearch.client.opensearch.OpenSearchClient client, org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter elasticsearchConverter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bulkUpdate(List<org.springframework.data.elasticsearch.core.query.UpdateQuery> queries, org.springframework.data.elasticsearch.core.query.BulkOptions bulkOptions, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    protected List<org.springframework.data.elasticsearch.core.IndexedObjectInformation>
    checkForBulkOperationFailure(org.opensearch.client.opensearch.core.BulkResponse bulkResponse)
    extract the list of IndexedObjectInformation from a BulkResponse.
     
    org.springframework.data.elasticsearch.core.cluster.ClusterOperations
     
    long
    count(org.springframework.data.elasticsearch.core.query.Query query, Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    org.springframework.data.elasticsearch.core.query.ByQueryResponse
    delete(org.springframework.data.elasticsearch.core.query.DeleteQuery query, Class<?> clazz)
     
    org.springframework.data.elasticsearch.core.query.ByQueryResponse
    delete(org.springframework.data.elasticsearch.core.query.DeleteQuery query, Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    org.springframework.data.elasticsearch.core.query.ByQueryResponse
    delete(org.springframework.data.elasticsearch.core.query.Query query, Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    boolean
     
    List<org.springframework.data.elasticsearch.core.IndexedObjectInformation>
    doBulkOperation(List<?> queries, org.springframework.data.elasticsearch.core.query.BulkOptions bulkOptions, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    protected org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
     
    protected String
    doDelete(String id, String routing, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    protected boolean
    doExists(String id, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    doIndex(org.springframework.data.elasticsearch.core.query.IndexQuery query, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates indexCoordinates)
     
    protected <T> org.springframework.data.elasticsearch.core.SearchHits<T>
    doSearch(org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    protected <T> org.springframework.data.elasticsearch.core.SearchHits<T>
    doSearch(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    protected <T> org.springframework.data.elasticsearch.core.SearchHits<T>
    doSearch(org.springframework.data.elasticsearch.core.query.SearchTemplateQuery query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    <T> T
    Execute a callback with the OpenSearchClient and provide exception translation.
    <T> T
    get(String id, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
     
     
    org.springframework.data.elasticsearch.core.script.Script
     
     
    org.springframework.data.elasticsearch.core.query.Query
     
    org.springframework.data.elasticsearch.core.IndexOperations
    indexOps(Class<?> clazz)
     
    org.springframework.data.elasticsearch.core.IndexOperations
    indexOps(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    Return all active point in time searches
    org.springframework.data.elasticsearch.core.query.Query
     
    <T> List<org.springframework.data.elasticsearch.core.MultiGetItem<T>>
    multiGet(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    <T> List<org.springframework.data.elasticsearch.core.SearchHits<T>>
    multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    List<org.springframework.data.elasticsearch.core.SearchHits<?>>
    multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes)
     
    List<org.springframework.data.elasticsearch.core.SearchHits<?>>
    multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes, List<org.springframework.data.elasticsearch.core.mapping.IndexCoordinates> indexes)
     
    List<org.springframework.data.elasticsearch.core.SearchHits<?>>
    multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    openPointInTime(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index, Duration keepAlive, Boolean ignoreUnavailable)
     
    boolean
    putScript(org.springframework.data.elasticsearch.core.script.Script script)
     
    org.springframework.data.elasticsearch.core.query.BaseQueryBuilder
     
    org.springframework.data.elasticsearch.core.reindex.ReindexResponse
    reindex(org.springframework.data.elasticsearch.core.reindex.ReindexRequest reindexRequest)
     
    <T> org.springframework.data.elasticsearch.core.SearchHits<T>
    search(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    void
     
    <T> org.springframework.data.elasticsearch.core.SearchScrollHits<T>
    searchScrollContinue(String scrollId, long scrollTimeInMillis, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    <T> org.springframework.data.elasticsearch.core.SearchScrollHits<T>
    searchScrollStart(long scrollTimeInMillis, org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    submitReindex(org.springframework.data.elasticsearch.core.reindex.ReindexRequest reindexRequest)
     
    org.springframework.data.elasticsearch.core.query.UpdateResponse
    update(org.springframework.data.elasticsearch.core.query.UpdateQuery updateQuery, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     
    org.springframework.data.elasticsearch.core.query.ByQueryResponse
    updateByQuery(org.springframework.data.elasticsearch.core.query.UpdateQuery updateQuery, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
     

    Methods inherited from class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate

    buildUpdateQueryByEntity, bulkIndex, bulkIndex, bulkIndex, bulkOperation, bulkUpdate, count, delete, delete, delete, delete, delete, exists, exists, get, getElasticsearchConverter, getEntityCreator, getEntityRouting, getIndexCoordinatesFor, getRefreshPolicy, index, logVersions, maybeCallbackAfterConvert, maybeCallbackAfterLoad, maybeCallbackAfterSave, maybeCallbackAfterSaveWithQueries, maybeCallbackAfterSaveWithQuery, maybeCallbackBeforeConvert, maybeCallbackBeforeConvertWithQueries, maybeCallbackBeforeConvertWithQuery, multiGet, multiSearch, save, save, save, save, save, search, search, search, searchForStream, searchForStream, searchScrollClear, setApplicationContext, setEntityCallbacks, setRefreshPolicy, toArray, update, update, updateIndexedObjectsWithQueries, withRefreshPolicy, withRouting

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.data.elasticsearch.core.DocumentOperations

    bulkIndex, bulkIndex, bulkIndex, bulkIndex, bulkUpdate, bulkUpdate, delete, delete, delete, delete, delete, exists, exists, get, index, multiGet, save, save, save, save, save, update, update

    Methods inherited from interface org.springframework.data.elasticsearch.core.ElasticsearchOperations

    convertId, getElasticsearchConverter, getEntityRouting, getIndexCoordinatesFor, withRefreshPolicy, withRouting

    Methods inherited from interface org.springframework.data.elasticsearch.core.SearchOperations

    count, count, multiSearch, openPointInTime, search, search, search, searchForStream, searchForStream, searchOne, searchOne
  • Constructor Details

    • OpenSearchTemplate

      public OpenSearchTemplate(org.opensearch.client.opensearch.OpenSearchClient client)
    • OpenSearchTemplate

      public OpenSearchTemplate(org.opensearch.client.opensearch.OpenSearchClient client, org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter elasticsearchConverter)
  • Method Details

    • doCopy

      protected org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate doCopy()
      Specified by:
      doCopy in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • indexOps

      public org.springframework.data.elasticsearch.core.IndexOperations indexOps(Class<?> clazz)
      Specified by:
      indexOps in interface org.springframework.data.elasticsearch.core.ElasticsearchOperations
    • indexOps

      public org.springframework.data.elasticsearch.core.IndexOperations indexOps(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      indexOps in interface org.springframework.data.elasticsearch.core.ElasticsearchOperations
    • cluster

      public org.springframework.data.elasticsearch.core.cluster.ClusterOperations cluster()
      Specified by:
      cluster in interface org.springframework.data.elasticsearch.core.ElasticsearchOperations
    • get

      @Nullable public <T> T get(String id, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      get in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • multiGet

      public <T> List<org.springframework.data.elasticsearch.core.MultiGetItem<T>> multiGet(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      multiGet in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • bulkUpdate

      public void bulkUpdate(List<org.springframework.data.elasticsearch.core.query.UpdateQuery> queries, org.springframework.data.elasticsearch.core.query.BulkOptions bulkOptions, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      bulkUpdate in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • delete

      public org.springframework.data.elasticsearch.core.query.ByQueryResponse delete(org.springframework.data.elasticsearch.core.query.DeleteQuery query, Class<?> clazz)
      Specified by:
      delete in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • delete

      public org.springframework.data.elasticsearch.core.query.ByQueryResponse delete(org.springframework.data.elasticsearch.core.query.DeleteQuery query, Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      delete in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • delete

      public org.springframework.data.elasticsearch.core.query.ByQueryResponse delete(org.springframework.data.elasticsearch.core.query.Query query, Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      delete in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • update

      public org.springframework.data.elasticsearch.core.query.UpdateResponse update(org.springframework.data.elasticsearch.core.query.UpdateQuery updateQuery, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      update in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • updateByQuery

      public org.springframework.data.elasticsearch.core.query.ByQueryResponse updateByQuery(org.springframework.data.elasticsearch.core.query.UpdateQuery updateQuery, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      updateByQuery in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • doIndex

      public String doIndex(org.springframework.data.elasticsearch.core.query.IndexQuery query, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates indexCoordinates)
      Specified by:
      doIndex in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • doExists

      protected boolean doExists(String id, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      doExists in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • doDelete

      protected String doDelete(String id, @Nullable String routing, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      doDelete in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • reindex

      public org.springframework.data.elasticsearch.core.reindex.ReindexResponse reindex(org.springframework.data.elasticsearch.core.reindex.ReindexRequest reindexRequest)
      Specified by:
      reindex in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • submitReindex

      public String submitReindex(org.springframework.data.elasticsearch.core.reindex.ReindexRequest reindexRequest)
      Specified by:
      submitReindex in interface org.springframework.data.elasticsearch.core.DocumentOperations
    • doBulkOperation

      public List<org.springframework.data.elasticsearch.core.IndexedObjectInformation> doBulkOperation(List<?> queries, org.springframework.data.elasticsearch.core.query.BulkOptions bulkOptions, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      doBulkOperation in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • getClusterVersion

      public String getClusterVersion()
      Specified by:
      getClusterVersion in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • getVendor

      public String getVendor()
      Specified by:
      getVendor in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • getRuntimeLibraryVersion

      public String getRuntimeLibraryVersion()
      Specified by:
      getRuntimeLibraryVersion in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • count

      public long count(org.springframework.data.elasticsearch.core.query.Query query, @Nullable Class<?> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      count in interface org.springframework.data.elasticsearch.core.SearchOperations
    • search

      public <T> org.springframework.data.elasticsearch.core.SearchHits<T> search(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      search in interface org.springframework.data.elasticsearch.core.SearchOperations
    • doSearch

      protected <T> org.springframework.data.elasticsearch.core.SearchHits<T> doSearch(org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
    • doSearch

      protected <T> org.springframework.data.elasticsearch.core.SearchHits<T> doSearch(org.springframework.data.elasticsearch.core.query.SearchTemplateQuery query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
    • doSearch

      protected <T> org.springframework.data.elasticsearch.core.SearchHits<T> doSearch(org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      doSearch in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • searchScrollStart

      public <T> org.springframework.data.elasticsearch.core.SearchScrollHits<T> searchScrollStart(long scrollTimeInMillis, org.springframework.data.elasticsearch.core.query.Query query, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      searchScrollStart in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • searchScrollContinue

      public <T> org.springframework.data.elasticsearch.core.SearchScrollHits<T> searchScrollContinue(String scrollId, long scrollTimeInMillis, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      searchScrollContinue in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • searchScrollClear

      public void searchScrollClear(List<String> scrollIds)
      Specified by:
      searchScrollClear in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • multiSearch

      public <T> List<org.springframework.data.elasticsearch.core.SearchHits<T>> multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, Class<T> clazz, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      multiSearch in interface org.springframework.data.elasticsearch.core.SearchOperations
    • multiSearch

      public List<org.springframework.data.elasticsearch.core.SearchHits<?>> multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes)
      Specified by:
      multiSearch in interface org.springframework.data.elasticsearch.core.SearchOperations
    • multiSearch

      public List<org.springframework.data.elasticsearch.core.SearchHits<?>> multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes, org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index)
      Specified by:
      multiSearch in interface org.springframework.data.elasticsearch.core.SearchOperations
    • multiSearch

      public List<org.springframework.data.elasticsearch.core.SearchHits<?>> multiSearch(List<? extends org.springframework.data.elasticsearch.core.query.Query> queries, List<Class<?>> classes, List<org.springframework.data.elasticsearch.core.mapping.IndexCoordinates> indexes)
      Specified by:
      multiSearch in interface org.springframework.data.elasticsearch.core.SearchOperations
    • openPointInTime

      public String openPointInTime(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates index, Duration keepAlive, Boolean ignoreUnavailable)
      Specified by:
      openPointInTime in interface org.springframework.data.elasticsearch.core.SearchOperations
      Overrides:
      openPointInTime in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • closePointInTime

      public Boolean closePointInTime(String pit)
      Specified by:
      closePointInTime in interface org.springframework.data.elasticsearch.core.SearchOperations
      Overrides:
      closePointInTime in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • listPointInTime

      public List<OpenSearchOperations.PitInfo> listPointInTime()
      Description copied from interface: OpenSearchOperations
      Return all active point in time searches
      Specified by:
      listPointInTime in interface OpenSearchOperations
      Returns:
      all active point in time searches
    • putScript

      public boolean putScript(org.springframework.data.elasticsearch.core.script.Script script)
      Specified by:
      putScript in interface org.springframework.data.elasticsearch.core.script.ScriptOperations
      Overrides:
      putScript in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • getScript

      @Nullable public org.springframework.data.elasticsearch.core.script.Script getScript(String name)
      Specified by:
      getScript in interface org.springframework.data.elasticsearch.core.script.ScriptOperations
      Overrides:
      getScript in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • deleteScript

      public boolean deleteScript(String name)
      Specified by:
      deleteScript in interface org.springframework.data.elasticsearch.core.script.ScriptOperations
      Overrides:
      deleteScript in class org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate
    • execute

      public <T> T execute(OpenSearchTemplate.ClientCallback<T> callback)
      Execute a callback with the OpenSearchClient and provide exception translation.
      Type Parameters:
      T - the type returned from the callback
      Parameters:
      callback - the callback to execute, must not be null
      Returns:
      the callback result
    • matchAllQuery

      public org.springframework.data.elasticsearch.core.query.Query matchAllQuery()
      Specified by:
      matchAllQuery in interface org.springframework.data.elasticsearch.core.SearchOperations
    • idsQuery

      public org.springframework.data.elasticsearch.core.query.Query idsQuery(List<String> ids)
      Specified by:
      idsQuery in interface org.springframework.data.elasticsearch.core.SearchOperations
    • queryBuilderWithIds

      public org.springframework.data.elasticsearch.core.query.BaseQueryBuilder queryBuilderWithIds(List<String> ids)
      Specified by:
      queryBuilderWithIds in interface org.springframework.data.elasticsearch.core.SearchOperations
    • checkForBulkOperationFailure

      protected List<org.springframework.data.elasticsearch.core.IndexedObjectInformation> checkForBulkOperationFailure(org.opensearch.client.opensearch.core.BulkResponse bulkResponse)
      extract the list of IndexedObjectInformation from a BulkResponse.
      Parameters:
      bulkResponse - the response to evaluate
      Returns:
      the list of the IndexedObjectInformations