Interface SearchClient
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
InMemorySearchStore
,WebSocketSearchClient
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 Summary
Modifier and TypeMethodDescriptionbulkUpdate
(Collection<DocumentUpdate> updates, Guarantee guarantee) Performs a batch update on a set of documents.void
close()
Closes any underlying resources.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.default CompletableFuture
<Void> deleteCollection
(String collection) Deletes an entire document collection and all its contents.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.
-
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 indexguarantee
- delivery guarantee (seeGuarantee
)ifNotExists
- iftrue
, only index documents that do not already exist- Returns:
- a future that completes when the operation is done
-
search
Executes a streaming search query using the given criteria and fetch size.- 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
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
Deletes documents matching a given query.- Parameters:
query
- the search query specifying which documents to deleteguarantee
- delivery guarantee- Returns:
- a future that completes when the deletion has been performed
-
delete
Deletes a document by its unique id and collection name.- Parameters:
documentId
- the document idcollection
- the collection to delete fromguarantee
- delivery guarantee- Returns:
- a future that completes when the deletion has been performed
-
createAuditTrail
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
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
Deletes an entire document collection and all its contents.- Parameters:
collection
- the name of the collection to deleteguarantee
- delivery guarantee- Returns:
- a future that completes when the collection has been deleted
-
fetchStatistics
Retrieves search statistics (counts, averages, etc.) over matching documents.- 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
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
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
Performs a batch update on a set of documents.- Parameters:
updates
- the update operations to performguarantee
- delivery guarantee- Returns:
- a future that completes when the updates have been applied
-
close
void close()Closes any underlying resources.- Specified by:
close
in interfaceAutoCloseable
-