Class WebSocketSearchClient
- All Implemented Interfaces:
WebsocketEndpoint, SearchClient, AutoCloseable
SearchClient that connects to the Fluxzero Runtime.
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 Fluxzero Runtime's search module.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractWebsocketClient
AbstractWebsocketClient.ClientHandshakeConfigurator, AbstractWebsocketClient.ConnectionSetup, AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.PreparedRequest<R>, AbstractWebsocketClient.WebSocketRequestNested classes/interfaces inherited from interface WebsocketEndpoint
WebsocketEndpoint.ReceiveTiming -
Field Summary
Fields inherited from class AbstractWebsocketClient
CLIENT_HANDSHAKE_CONFIGURATOR_USER_PROPERTY, CLIENT_SESSION_ID_USER_PROPERTY, CONNECTION_RETRY_LOG_INTERVAL, CONNECTION_TIMEOUT_FAILSAFE_GRACE, defaultObjectMapper, defaultWebsocketConnector, NEGOTIATED_SESSION_ID_USER_PROPERTY, RUNTIME_SESSION_ID_USER_PROPERTY, RUNTIME_VERSION_USER_PROPERTY, SELECTED_COMPRESSION_ALGORITHM_USER_PROPERTY, SELECTED_TRANSPORT_FORMAT_USER_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketSearchClient(String endPointUrl, WebSocketClient client) WebSocketSearchClient(URI endpointUri, WebSocketClient client) WebSocketSearchClient(URI endpointUri, WebSocketClient client, boolean sendMetrics) -
Method Summary
Modifier and TypeMethodDescriptionadoptModelMigration(io.fluxzero.common.api.search.AdoptModelMigration request) Atomically adopts a previously inspected and application-verified staged Model document while retaining the accepted normalized source until an ordinary Model write ends legacy-write coexistence.bulkUpdate(Collection<io.fluxzero.common.api.search.DocumentUpdate> batch, io.fluxzero.common.Guarantee guarantee) Performs a batch update on a set of documents.createAuditTrail(io.fluxzero.common.api.search.CreateAuditTrail request) Configures Fluxzero to use a search collection as a searchable audit trail.delete(io.fluxzero.common.api.search.SearchQuery query, io.fluxzero.common.Guarantee guarantee, int batchSize) Deletes documents matching a given query using the requested batch size.Deletes a document by its unique id and collection name.deleteCollection(String collection, io.fluxzero.common.Guarantee guarantee) Deletes an entire document collection and all its contents.booleandocumentExists(io.fluxzero.common.api.search.HasDocument request) Checks whether a document with the given criteria exists.Optional<io.fluxzero.common.api.search.SerializedDocument> fetch(io.fluxzero.common.api.search.GetDocument request) Fetches a single serialized document matching the given request.Collection<io.fluxzero.common.api.search.SerializedDocument> fetch(io.fluxzero.common.api.search.GetDocuments request) Fetches a collection of serialized documents that match the given request.List<io.fluxzero.common.api.search.FacetStats> fetchFacetStats(io.fluxzero.common.api.search.SearchQuery query) Retrieves facet statistics (i.e., value counts) for a given query.CompletableFuture<List<io.fluxzero.common.api.search.FacetStats>> fetchFacetStatsAsync(io.fluxzero.common.api.search.SearchQuery query) Asynchronously retrieves facet statistics for a given query.io.fluxzero.common.api.search.SearchHistogramfetchHistogram(io.fluxzero.common.api.search.GetSearchHistogram request) Fetches a histogram (bucketed time-series view) for documents matching the query.CompletableFuture<io.fluxzero.common.api.search.SearchHistogram> fetchHistogramAsync(io.fluxzero.common.api.search.GetSearchHistogram request) Asynchronously fetches a histogram for documents matching the query.io.fluxzero.common.api.search.GetDocumentResultfetchModelDocument(io.fluxzero.common.api.search.GetDocument request) Fetches a direct Model document together with the durable head written by the same materialization transaction.List<io.fluxzero.common.api.search.DocumentStats> fetchStatistics(io.fluxzero.common.api.search.SearchQuery query, List<String> fields, List<String> groupBy) Retrieves search statistics (counts, averages, etc.) over matching documents.CompletableFuture<List<io.fluxzero.common.api.search.DocumentStats>> fetchStatisticsAsync(io.fluxzero.common.api.search.SearchQuery query, List<String> fields, List<String> groupBy) Asynchronously retrieves search statistics over matching documents.io.fluxzero.common.api.search.GetModelMigrationResultgetModelMigration(io.fluxzero.common.api.search.GetModelMigration request) Retrieves the production and staged direct documents used to verify one Model migration.io.fluxzero.common.api.search.GetModelMigrationsResultgetModelMigrations(io.fluxzero.common.api.search.GetModelMigrations request) Retrieves a bounded batch of staged direct Model migrations.List<io.fluxzero.common.api.search.SearchCollection> Retrieves existing regular search collections and audit trails.index(List<io.fluxzero.common.api.search.SerializedDocument> documents, io.fluxzero.common.Guarantee guarantee, boolean ifNotExists) Indexes a list of serialized documents into the search engine.move(io.fluxzero.common.api.search.SearchQuery query, String targetCollection, io.fluxzero.common.Guarantee guarantee) Moves documents matching a given query to the given target collection.move(String documentId, String collection, String targetCollection, io.fluxzero.common.Guarantee guarantee) Moves a document to another collection.rewriteModelGraphDocument(io.fluxzero.common.api.search.SerializedDocument document, String expectedManifest, io.fluxzero.common.Guarantee guarantee) Conditionally replaces one materialized model-graph document while its manifest still matches the handled version.search(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) Executes a streaming search query using the given criteria and fetch size.CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchAsync(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) Asynchronously executes a search query using the given criteria and fetch size and materializes the matching hits.searchModelGraph(io.fluxzero.common.api.search.SearchModelGraphDocuments searchDocuments, int fetchSize) Executes a current-state model search and composes each matching root's explicitly placed child graph.CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchModelGraphAsync(io.fluxzero.common.api.search.SearchModelGraphDocuments searchDocuments, int fetchSize) Asynchronously searches and composes current independent-model graphs.searchModels(io.fluxzero.common.api.search.SearchModelDocuments searchDocuments, int fetchSize) Executes a bounded current-state search across independent model relationships.CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchModelsAsync(io.fluxzero.common.api.search.SearchModelDocuments searchDocuments, int fetchSize) Asynchronously executes a bounded current-state search across independent model relationships.Methods inherited from class AbstractWebsocketClient
abort, captureReceiveTiming, close, close, connectToServer, connectToServer, createConnectionRetryConfiguration, createConnectionSetup, createConnectionSetup, getCloseHandshakeTimeout, getCompressionAlgorithm, getConnectionTimeoutFailsafeGrace, getNegotiatedSessionId, getRuntimeVersion, getTransportFormat, handleClose, handleError, handleMessage, handlePong, handleResult, handleResult, jfrResultType, logConnectionRetryStatus, logSuccessfulReconnect, maxRequestBatchSize, metricsMetadata, nextReconnectJitter, onClose, onError, onMessage, onMessage, onOpen, onPong, outstandingRequest, payloadCodecs, prepareRequest, prepareRequest, prepareResults, restoreResultContext, restoreResultContext, retryOutstandingRequests, retryOutstandingRequestsAsync, retryOutstandingRequestsDelay, schedulePing, send, send, sendAndWait, sendCommand, sendPing, sendPreparedRequests, startRequestBatchEvent, toString, transportCodec, transportMetricPublicationTimeout, tryPublishMetricsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface SearchClient
close, delete, deleteCollection
-
Constructor Details
-
WebSocketSearchClient
-
WebSocketSearchClient
-
WebSocketSearchClient
-
-
Method Details
-
getSearchCollections
Description copied from interface:SearchClientRetrieves existing regular search collections and audit trails.Implementations predating this operation may throw
UnsupportedOperationException.- Specified by:
getSearchCollectionsin interfaceSearchClient- Returns:
- the available collections with their storage types, in deterministic order
-
index
public CompletableFuture<Void> index(List<io.fluxzero.common.api.search.SerializedDocument> documents, io.fluxzero.common.Guarantee guarantee, boolean ifNotExists) Description copied from interface:SearchClientIndexes a list of serialized documents into the search engine.- Specified by:
indexin interfaceSearchClient- Parameters:
documents- the documents to indexguarantee- delivery guarantee (seeGuarantee)ifNotExists- iftrue, only index documents that do not already exist- Returns:
- a future that completes when the operation is done
-
rewriteModelGraphDocument
public CompletableFuture<Void> rewriteModelGraphDocument(io.fluxzero.common.api.search.SerializedDocument document, String expectedManifest, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientConditionally replaces one materialized model-graph document while its manifest still matches the handled version. Implementations without durable model-graph projections may retain the unsupported default.- Specified by:
rewriteModelGraphDocumentin interfaceSearchClient
-
bulkUpdate
public CompletableFuture<Void> bulkUpdate(Collection<io.fluxzero.common.api.search.DocumentUpdate> batch, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientPerforms a batch update on a set of documents.- Specified by:
bulkUpdatein interfaceSearchClient- Parameters:
batch- the update operations to performguarantee- delivery guarantee- Returns:
- a future that completes when the updates have been applied
-
search
public Stream<SearchHit<io.fluxzero.common.api.search.SerializedDocument>> search(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientExecutes a streaming search query using the given criteria and fetch size.- Specified by:
searchin interfaceSearchClient- Parameters:
searchDocuments- the search parameters and queryfetchSize- the number of results to fetch per page- Returns:
- a stream of search hits matching the query
-
searchAsync
public CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchAsync(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientAsynchronously executes a search query using the given criteria and fetch size and materializes the matching hits.The default implementation adapts
SearchClient.search(SearchDocuments, int)to a future. Remote clients can override this method to use a native asynchronous transport.- Specified by:
searchAsyncin interfaceSearchClient- Parameters:
searchDocuments- the search parameters and queryfetchSize- the number of results to fetch per page- Returns:
- a future with search hits matching the query
-
searchModels
public Stream<SearchHit<io.fluxzero.common.api.search.SerializedDocument>> searchModels(io.fluxzero.common.api.search.SearchModelDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientExecutes a bounded current-state search across independent model relationships.- Specified by:
searchModelsin interfaceSearchClient
-
searchModelsAsync
public CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchModelsAsync(io.fluxzero.common.api.search.SearchModelDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientAsynchronously executes a bounded current-state search across independent model relationships.- Specified by:
searchModelsAsyncin interfaceSearchClient
-
searchModelGraph
public Stream<SearchHit<io.fluxzero.common.api.search.SerializedDocument>> searchModelGraph(io.fluxzero.common.api.search.SearchModelGraphDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientExecutes a current-state model search and composes each matching root's explicitly placed child graph.- Specified by:
searchModelGraphin interfaceSearchClient
-
searchModelGraphAsync
public CompletableFuture<List<SearchHit<io.fluxzero.common.api.search.SerializedDocument>>> searchModelGraphAsync(io.fluxzero.common.api.search.SearchModelGraphDocuments searchDocuments, int fetchSize) Description copied from interface:SearchClientAsynchronously searches and composes current independent-model graphs.- Specified by:
searchModelGraphAsyncin interfaceSearchClient
-
documentExists
public boolean documentExists(io.fluxzero.common.api.search.HasDocument request) Description copied from interface:SearchClientChecks whether a document with the given criteria exists.- Specified by:
documentExistsin interfaceSearchClient- Parameters:
request- an object describing the document (e.g., id and collection)- Returns:
trueif the document exists,falseotherwise
-
fetch
public Optional<io.fluxzero.common.api.search.SerializedDocument> fetch(io.fluxzero.common.api.search.GetDocument request) Description copied from interface:SearchClientFetches a single serialized document matching the given request.- Specified by:
fetchin interfaceSearchClient- Parameters:
request- an object describing the document to retrieve- Returns:
- an optional containing the document, if found
-
fetchModelDocument
public io.fluxzero.common.api.search.GetDocumentResult fetchModelDocument(io.fluxzero.common.api.search.GetDocument request) Description copied from interface:SearchClientFetches a direct Model document together with the durable head written by the same materialization transaction.- Specified by:
fetchModelDocumentin interfaceSearchClient
-
getModelMigration
public io.fluxzero.common.api.search.GetModelMigrationResult getModelMigration(io.fluxzero.common.api.search.GetModelMigration request) Description copied from interface:SearchClientRetrieves the production and staged direct documents used to verify one Model migration.- Specified by:
getModelMigrationin interfaceSearchClient
-
getModelMigrations
public io.fluxzero.common.api.search.GetModelMigrationsResult getModelMigrations(io.fluxzero.common.api.search.GetModelMigrations request) Description copied from interface:SearchClientRetrieves a bounded batch of staged direct Model migrations.- Specified by:
getModelMigrationsin interfaceSearchClient
-
adoptModelMigration
public CompletableFuture<Void> adoptModelMigration(io.fluxzero.common.api.search.AdoptModelMigration request) Description copied from interface:SearchClientAtomically adopts a previously inspected and application-verified staged Model document while retaining the accepted normalized source until an ordinary Model write ends legacy-write coexistence.- Specified by:
adoptModelMigrationin interfaceSearchClient
-
fetch
public Collection<io.fluxzero.common.api.search.SerializedDocument> fetch(io.fluxzero.common.api.search.GetDocuments request) Description copied from interface:SearchClientFetches a collection of serialized documents that match the given request.- Specified by:
fetchin interfaceSearchClient- Parameters:
request- an object describing the documents to retrieve- Returns:
- a collection of retrieved documents matching
-
fetchStatistics
public List<io.fluxzero.common.api.search.DocumentStats> fetchStatistics(io.fluxzero.common.api.search.SearchQuery query, List<String> fields, List<String> groupBy) Description copied from interface:SearchClientRetrieves search statistics (counts, averages, etc.) over matching documents.- Specified by:
fetchStatisticsin interfaceSearchClient- Parameters:
query- the query to filter documentsfields- the fields to compute statistics forgroupBy- field names used to group statistics- Returns:
- a list of
DocumentStats
-
fetchStatisticsAsync
public CompletableFuture<List<io.fluxzero.common.api.search.DocumentStats>> fetchStatisticsAsync(io.fluxzero.common.api.search.SearchQuery query, List<String> fields, List<String> groupBy) Description copied from interface:SearchClientAsynchronously retrieves search statistics over matching documents.The default implementation adapts
SearchClient.fetchStatistics(SearchQuery, List, List)to a future. Remote clients can override this method to use a native asynchronous transport.- Specified by:
fetchStatisticsAsyncin interfaceSearchClient- Parameters:
query- the query to filter documentsfields- the fields to compute statistics forgroupBy- field names used to group statistics- Returns:
- a future with search statistics
-
fetchHistogram
public io.fluxzero.common.api.search.SearchHistogram fetchHistogram(io.fluxzero.common.api.search.GetSearchHistogram request) Description copied from interface:SearchClientFetches a histogram (bucketed time-series view) for documents matching the query.- Specified by:
fetchHistogramin interfaceSearchClient- Parameters:
request- the histogram query parameters- Returns:
- a
SearchHistogramrepresenting the result
-
fetchHistogramAsync
public CompletableFuture<io.fluxzero.common.api.search.SearchHistogram> fetchHistogramAsync(io.fluxzero.common.api.search.GetSearchHistogram request) Description copied from interface:SearchClientAsynchronously fetches a histogram for documents matching the query.The default implementation adapts
SearchClient.fetchHistogram(GetSearchHistogram)to a future. Remote clients can override this method to use a native asynchronous transport.- Specified by:
fetchHistogramAsyncin interfaceSearchClient- Parameters:
request- the histogram query parameters- Returns:
- a future with the histogram for matching documents
-
fetchFacetStats
public List<io.fluxzero.common.api.search.FacetStats> fetchFacetStats(io.fluxzero.common.api.search.SearchQuery query) Description copied from interface:SearchClientRetrieves facet statistics (i.e., value counts) for a given query.- Specified by:
fetchFacetStatsin interfaceSearchClient- Parameters:
query- the query to match documents against- Returns:
- a list of facet statistics
-
fetchFacetStatsAsync
public CompletableFuture<List<io.fluxzero.common.api.search.FacetStats>> fetchFacetStatsAsync(io.fluxzero.common.api.search.SearchQuery query) Description copied from interface:SearchClientAsynchronously retrieves facet statistics for a given query.The default implementation adapts
SearchClient.fetchFacetStats(SearchQuery)to a future. Remote clients can override this method to use a native asynchronous transport.- Specified by:
fetchFacetStatsAsyncin interfaceSearchClient- Parameters:
query- the query to match documents against- Returns:
- a future with facet statistics
-
delete
public CompletableFuture<Void> delete(io.fluxzero.common.api.search.SearchQuery query, io.fluxzero.common.Guarantee guarantee, int batchSize) Description copied from interface:SearchClientDeletes documents matching a given query using the requested batch size.A value of
0uses the runtime default, a positive value requests that batch size, and a negative value requests a single unbounded statement.- Specified by:
deletein interfaceSearchClient- Parameters:
query- the search query specifying which documents to deleteguarantee- delivery guaranteebatchSize- requested delete batch size- Returns:
- a future that completes when the deletion has been performed
-
move
public CompletableFuture<Void> move(io.fluxzero.common.api.search.SearchQuery query, String targetCollection, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientMoves documents matching a given query to the given target collection.- Specified by:
movein interfaceSearchClient- Parameters:
query- the search query specifying which documents to movetargetCollection- the name of the collection to move documents toguarantee- delivery guarantee- Returns:
- a future that completes when the move has been performed
-
delete
public CompletableFuture<Void> delete(String documentId, String collection, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientDeletes a document by its unique id and collection name.- Specified by:
deletein interfaceSearchClient- Parameters:
documentId- the document idcollection- the collection to delete fromguarantee- delivery guarantee- Returns:
- a future that completes when the deletion has been performed
-
move
public CompletableFuture<Void> move(String documentId, String collection, String targetCollection, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientMoves a document to another collection.- Specified by:
movein interfaceSearchClient- Parameters:
documentId- the document idcollection- the collection to move fromtargetCollection- the collection to move toguarantee- delivery guarantee- Returns:
- a future that completes when the move has been performed
-
deleteCollection
public CompletableFuture<Void> deleteCollection(String collection, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SearchClientDeletes an entire document collection and all its contents.- Specified by:
deleteCollectionin interfaceSearchClient- Parameters:
collection- the name of the collection to deleteguarantee- delivery guarantee- Returns:
- a future that completes when the collection has been deleted
-
createAuditTrail
public CompletableFuture<Void> createAuditTrail(io.fluxzero.common.api.search.CreateAuditTrail request) Description copied from interface:SearchClientConfigures Fluxzero to use a search collection as a searchable audit trail.- Specified by:
createAuditTrailin interfaceSearchClient- 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.
-