Class WebSocketSearchClient

java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.persisting.search.client.WebSocketSearchClient
All Implemented Interfaces:
SearchClient, AutoCloseable

public class WebSocketSearchClient extends AbstractWebsocketClient implements SearchClient
WebSocket-based implementation of the SearchClient that connects to the Flux platform.

All operations (indexing, searching, deletion, statistics, etc.) are executed via a WebSocket protocol using a standardized API. This is the default production implementation used in deployed applications.

Requires an active connection to the Flux platform's search module.

See Also:
  • Constructor Details

    • WebSocketSearchClient

      public WebSocketSearchClient(String endPointUrl, WebSocketClient client)
    • WebSocketSearchClient

      public WebSocketSearchClient(URI endpointUri, WebSocketClient client)
    • WebSocketSearchClient

      public WebSocketSearchClient(URI endpointUri, WebSocketClient client, boolean sendMetrics)
  • Method Details

    • index

      public CompletableFuture<Void> index(List<SerializedDocument> documents, Guarantee guarantee, boolean ifNotExists)
      Description copied from interface: SearchClient
      Indexes a list of serialized documents into the search engine.
      Specified by:
      index in interface SearchClient
      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
    • bulkUpdate

      public CompletableFuture<Void> bulkUpdate(Collection<DocumentUpdate> batch, Guarantee guarantee)
      Description copied from interface: SearchClient
      Performs a batch update on a set of documents.
      Specified by:
      bulkUpdate in interface SearchClient
      Parameters:
      batch - the update operations to perform
      guarantee - delivery guarantee
      Returns:
      a future that completes when the updates have been applied
    • search

      public Stream<SearchHit<SerializedDocument>> search(SearchDocuments searchDocuments, int fetchSize)
      Description copied from interface: SearchClient
      Executes a streaming search query using the given criteria and fetch size.
      Specified by:
      search in interface SearchClient
      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

      public boolean documentExists(HasDocument request)
      Description copied from interface: SearchClient
      Checks whether a document with the given criteria exists.
      Specified by:
      documentExists in interface SearchClient
      Parameters:
      request - an object describing the document (e.g., id and collection)
      Returns:
      true if the document exists, false otherwise
    • fetch

      public Optional<SerializedDocument> fetch(GetDocument request)
      Description copied from interface: SearchClient
      Fetches a single serialized document matching the given request.
      Specified by:
      fetch in interface SearchClient
      Parameters:
      request - an object describing the document to retrieve
      Returns:
      an optional containing the document, if found
    • fetchStatistics

      public List<DocumentStats> fetchStatistics(SearchQuery query, List<String> fields, List<String> groupBy)
      Description copied from interface: SearchClient
      Retrieves search statistics (counts, averages, etc.) over matching documents.
      Specified by:
      fetchStatistics in interface SearchClient
      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

      public SearchHistogram fetchHistogram(GetSearchHistogram request)
      Description copied from interface: SearchClient
      Fetches a histogram (bucketed time-series view) for documents matching the query.
      Specified by:
      fetchHistogram in interface SearchClient
      Parameters:
      request - the histogram query parameters
      Returns:
      a SearchHistogram representing the result
    • fetchFacetStats

      public List<FacetStats> fetchFacetStats(SearchQuery query)
      Description copied from interface: SearchClient
      Retrieves facet statistics (i.e., value counts) for a given query.
      Specified by:
      fetchFacetStats in interface SearchClient
      Parameters:
      query - the query to match documents against
      Returns:
      a list of facet statistics
    • delete

      public CompletableFuture<Void> delete(SearchQuery query, Guarantee guarantee)
      Description copied from interface: SearchClient
      Deletes documents matching a given query.
      Specified by:
      delete in interface SearchClient
      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

      public CompletableFuture<Void> delete(String documentId, String collection, Guarantee guarantee)
      Description copied from interface: SearchClient
      Deletes a document by its unique id and collection name.
      Specified by:
      delete in interface SearchClient
      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
    • deleteCollection

      public CompletableFuture<Void> deleteCollection(String collection, Guarantee guarantee)
      Description copied from interface: SearchClient
      Deletes an entire document collection and all its contents.
      Specified by:
      deleteCollection in interface SearchClient
      Parameters:
      collection - the name of the collection to delete
      guarantee - delivery guarantee
      Returns:
      a future that completes when the collection has been deleted
    • createAuditTrail

      public CompletableFuture<Void> createAuditTrail(CreateAuditTrail request)
      Description copied from interface: SearchClient
      Configures Flux to use a search collection as a searchable audit trail.
      Specified by:
      createAuditTrail in interface SearchClient
      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.