Class WebSocketSearchClient
java.lang.Object
io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
io.fluxcapacitor.javaclient.persisting.search.client.WebSocketSearchClient
- All Implemented Interfaces:
SearchClient
,AutoCloseable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
AbstractWebsocketClient.PingRegistration, AbstractWebsocketClient.WebSocketRequest
-
Field Summary
Fields inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
defaultObjectMapper, defaultWebSocketContainer
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketSearchClient
(String endPointUrl, WebSocketClient client) WebSocketSearchClient
(URI endpointUri, WebSocketClient client) WebSocketSearchClient
(URI endpointUri, WebSocketClient client, boolean sendMetrics) -
Method Summary
Modifier and TypeMethodDescriptionbulkUpdate
(Collection<DocumentUpdate> batch, Guarantee guarantee) Performs a batch update on a set of documents.createAuditTrail
(CreateAuditTrail request) Configures Flux to use a search collection as a searchable audit trail.delete
(SearchQuery query, Guarantee guarantee) Deletes documents matching a given query.Deletes a document by its unique id and collection name.deleteCollection
(String collection, Guarantee guarantee) Deletes an entire document collection and all its contents.boolean
documentExists
(HasDocument request) Checks whether a document with the given criteria exists.fetch
(GetDocument request) Fetches a single serialized document matching the given request.fetchFacetStats
(SearchQuery query) Retrieves facet statistics (i.e., value counts) for a given query.fetchHistogram
(GetSearchHistogram request) Fetches a histogram (bucketed time-series view) for documents matching the query.fetchStatistics
(SearchQuery query, List<String> fields, List<String> groupBy) Retrieves search statistics (counts, averages, etc.) over matching documents.index
(List<SerializedDocument> documents, Guarantee guarantee, boolean ifNotExists) Indexes a list of serialized documents into the search engine.search
(SearchDocuments searchDocuments, int fetchSize) Executes a streaming search query using the given criteria and fetch size.Methods inherited from class io.fluxcapacitor.javaclient.common.websocket.AbstractWebsocketClient
abort, close, close, handleResult, metricsMetadata, onClose, onError, onMessage, onOpen, onPong, retryOutstandingRequests, schedulePing, send, sendAndWait, sendCommand, sendPing, toString, tryPublishMetrics
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.persisting.search.client.SearchClient
close, deleteCollection
-
Constructor Details
-
WebSocketSearchClient
-
WebSocketSearchClient
-
WebSocketSearchClient
-
-
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 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
-
bulkUpdate
Description copied from interface:SearchClient
Performs a batch update on a set of documents.- Specified by:
bulkUpdate
in interfaceSearchClient
- Parameters:
batch
- the update operations to performguarantee
- delivery guarantee- Returns:
- a future that completes when the updates have been applied
-
search
Description copied from interface:SearchClient
Executes a streaming search query using the given criteria and fetch size.- Specified by:
search
in 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
-
documentExists
Description copied from interface:SearchClient
Checks whether a document with the given criteria exists.- Specified by:
documentExists
in interfaceSearchClient
- Parameters:
request
- an object describing the document (e.g., id and collection)- Returns:
true
if the document exists,false
otherwise
-
fetch
Description copied from interface:SearchClient
Fetches a single serialized document matching the given request.- Specified by:
fetch
in interfaceSearchClient
- 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 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
-
fetchHistogram
Description copied from interface:SearchClient
Fetches a histogram (bucketed time-series view) for documents matching the query.- Specified by:
fetchHistogram
in interfaceSearchClient
- Parameters:
request
- the histogram query parameters- Returns:
- a
SearchHistogram
representing the result
-
fetchFacetStats
Description copied from interface:SearchClient
Retrieves facet statistics (i.e., value counts) for a given query.- Specified by:
fetchFacetStats
in interfaceSearchClient
- Parameters:
query
- the query to match documents against- Returns:
- a list of facet statistics
-
delete
Description copied from interface:SearchClient
Deletes documents matching a given query.- Specified by:
delete
in interfaceSearchClient
- Parameters:
query
- the search query specifying which documents to deleteguarantee
- delivery guarantee- Returns:
- a future that completes when the deletion has been performed
-
delete
Description copied from interface:SearchClient
Deletes a document by its unique id and collection name.- Specified by:
delete
in interfaceSearchClient
- Parameters:
documentId
- the document idcollection
- the collection to delete fromguarantee
- delivery guarantee- Returns:
- a future that completes when the deletion has been performed
-
deleteCollection
Description copied from interface:SearchClient
Deletes an entire document collection and all its contents.- Specified by:
deleteCollection
in interfaceSearchClient
- Parameters:
collection
- the name of the collection to deleteguarantee
- delivery guarantee- Returns:
- a future that completes when the collection has been deleted
-
createAuditTrail
Description copied from interface:SearchClient
Configures Flux to use a search collection as a searchable audit trail.- Specified by:
createAuditTrail
in 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.
-