All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
InMemorySearchStore, WebSocketSearchClient

public interface SearchClient extends AutoCloseable
Low-level interface for interacting with a search and indexing service in Flux.

The SearchClient operates exclusively on serialized forms of documents (see SerializedDocument) and search-related requests. It is the primary interface used by internal components like DocumentStore to execute actual search operations against a backing implementation (e.g., Flux platform or an in-memory search engine for testing).

See Also:
  • Method Details

    • index

      CompletableFuture<Void> index(List<SerializedDocument> documents, Guarantee guarantee, boolean ifNotExists)
      Indexes a list of serialized documents into the search engine.
      Parameters:
      documents - the documents to index
      guarantee - delivery guarantee (see Guarantee)
      ifNotExists - if true, only index documents that do not already exist
      Returns:
      a future that completes when the operation is done
    • search

      Stream<SearchHit<SerializedDocument>> search(SearchDocuments searchDocuments, int fetchSize)
      Executes a streaming search query using the given criteria and fetch size.
      Parameters:
      searchDocuments - the search parameters and query
      fetchSize - the number of results to fetch per page
      Returns:
      a stream of search hits matching the query
    • documentExists

      boolean documentExists(HasDocument request)
      Checks whether a document with the given criteria exists.
      Parameters:
      request - an object describing the document (e.g., id and collection)
      Returns:
      true if the document exists, false otherwise
    • fetch

      Fetches a single serialized document matching the given request.
      Parameters:
      request - an object describing the document to retrieve
      Returns:
      an optional containing the document, if found
    • delete

      CompletableFuture<Void> delete(SearchQuery query, Guarantee guarantee)
      Deletes documents matching a given query.
      Parameters:
      query - the search query specifying which documents to delete
      guarantee - delivery guarantee
      Returns:
      a future that completes when the deletion has been performed
    • delete

      CompletableFuture<Void> delete(String documentId, String collection, Guarantee guarantee)
      Deletes a document by its unique id and collection name.
      Parameters:
      documentId - the document id
      collection - the collection to delete from
      guarantee - delivery guarantee
      Returns:
      a future that completes when the deletion has been performed
    • createAuditTrail

      CompletableFuture<Void> createAuditTrail(CreateAuditTrail request)
      Configures Flux to use a search collection as a searchable audit trail.
      Parameters:
      request - a request object specifying the collection to use as an audit trail and retention configuration
      Returns:
      a future that completes when the audit trail has been created.
    • deleteCollection

      default CompletableFuture<Void> deleteCollection(String collection)
      Deletes an entire document collection and all its contents.
      Parameters:
      collection - the name of the collection to delete
      Returns:
      a future that completes when the collection has been deleted
    • deleteCollection

      CompletableFuture<Void> deleteCollection(String collection, Guarantee guarantee)
      Deletes an entire document collection and all its contents.
      Parameters:
      collection - the name of the collection to delete
      guarantee - delivery guarantee
      Returns:
      a future that completes when the collection has been deleted
    • fetchStatistics

      List<DocumentStats> fetchStatistics(SearchQuery query, List<String> fields, List<String> groupBy)
      Retrieves search statistics (counts, averages, etc.) over matching documents.
      Parameters:
      query - the query to filter documents
      fields - the fields to compute statistics for
      groupBy - field names used to group statistics
      Returns:
      a list of DocumentStats
    • fetchHistogram

      SearchHistogram fetchHistogram(GetSearchHistogram request)
      Fetches a histogram (bucketed time-series view) for documents matching the query.
      Parameters:
      request - the histogram query parameters
      Returns:
      a SearchHistogram representing the result
    • fetchFacetStats

      List<FacetStats> fetchFacetStats(SearchQuery query)
      Retrieves facet statistics (i.e., value counts) for a given query.
      Parameters:
      query - the query to match documents against
      Returns:
      a list of facet statistics
    • bulkUpdate

      CompletableFuture<Void> bulkUpdate(Collection<DocumentUpdate> updates, Guarantee guarantee)
      Performs a batch update on a set of documents.
      Parameters:
      updates - the update operations to perform
      guarantee - delivery guarantee
      Returns:
      a future that completes when the updates have been applied
    • close

      void close()
      Closes any underlying resources.
      Specified by:
      close in interface AutoCloseable