Interface SearchClient

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractSearchClient, OpenSearchSearchClient, RepositorySearchClient

public interface SearchClient extends AutoCloseable
Interface used by the SearchService to access an external Search Cluster. The client must take care of the retry mechanism, in case of failure to process a request or accessing the search backend a SearchClientException must be raised.
Since:
2025.0
  • Field Details

  • Method Details

    • getName

      String getName()
      Gets the client name.
    • isReady

      boolean isReady()
      Is the client ready and the search engine healthy to serve requests.
    • hasCapability

      boolean hasCapability(SearchClient.Capability capability)
      Checks whether the client has the capability.
    • getCapabilities

      Set<SearchClient.Capability> getCapabilities()
      Returns the supported capabilities.
    • dropIndex

      void dropIndex(String name)
      Drops an index.
    • dropAndInitIndex

      void dropAndInitIndex(String indexName)
      Recreate an existing index using the same settings and mapping.
    • indexDocuments

      BulkIndexingResponse indexDocuments(BulkIndexingRequest request)
      Index documents. Check the response for possible indexing failure.
      Throws:
      SearchClientException - when the search backend is not able to process the request after retries.
    • refresh

      void refresh(String indexName)
      Refreshes an index so newly indexed documents are searchable.
    • getDocument

      String getDocument(String indexName, String documentId)
      Returns a Json document representation or null if not found.
    • getDocumentVersion

      Long getDocumentVersion(String indexName, String documentId)
      Returns the version which is the timestamp when document was loaded for indexing
    • search

      SearchResponse search(SearchQuery query)
      Executes a search query.
    • searchScroll

      SearchResponse searchScroll(SearchScrollContext scrollContext)
      Iterate on results for a scroll search. The end of scroll is reached when there is no more hit, i.e. SearchResponse.getHitsCount() returns 0.
      Parameters:
      scrollContext - provided by the previous SearchResponse.getScrollContext();
    • clearScroll

      boolean clearScroll(SearchScrollContext scrollContext)
      Explicitly clear the search scroll context, without waiting for the scroll keep alive to timeout.
      Returns:
      true if the context is successfully cleared.
    • close

      void close()
      Specified by:
      close in interface AutoCloseable