- 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., Fluxzero Runtime or
an in-memory search engine for testing).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbulkUpdate(Collection<io.fluxzero.common.api.search.DocumentUpdate> updates, io.fluxzero.common.Guarantee guarantee) Performs a batch update on a set of documents.voidclose()Closes any underlying resources.createAuditTrail(io.fluxzero.common.api.search.CreateAuditTrail request) Configures Flux to use a search collection as a searchable audit trail.delete(io.fluxzero.common.api.search.SearchQuery query, io.fluxzero.common.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, 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.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.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.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.search(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) Executes a streaming search query using the given criteria and fetch size.
-
Method Details
-
index
CompletableFuture<Void> 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.- 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
Stream<SearchHit<io.fluxzero.common.api.search.SerializedDocument>> search(io.fluxzero.common.api.search.SearchDocuments searchDocuments, int fetchSize) 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
boolean documentExists(io.fluxzero.common.api.search.HasDocument request) Checks whether a document with the given criteria exists.- Parameters:
request- an object describing the document (e.g., id and collection)- Returns:
trueif the document exists,falseotherwise
-
fetch
Optional<io.fluxzero.common.api.search.SerializedDocument> fetch(io.fluxzero.common.api.search.GetDocument request) 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
-
fetch
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.- Parameters:
request- an object describing the documents to retrieve- Returns:
- a collection of retrieved documents matching
-
delete
CompletableFuture<Void> delete(io.fluxzero.common.api.search.SearchQuery query, io.fluxzero.common.Guarantee guarantee) 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
CompletableFuture<Void> delete(String documentId, String collection, io.fluxzero.common.Guarantee guarantee) 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
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.- 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
io.fluxzero.common.api.search.SearchHistogram fetchHistogram(io.fluxzero.common.api.search.GetSearchHistogram request) Fetches a histogram (bucketed time-series view) for documents matching the query.- Parameters:
request- the histogram query parameters- Returns:
- a
SearchHistogramrepresenting the result
-
fetchFacetStats
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.- Parameters:
query- the query to match documents against- Returns:
- a list of facet statistics
-
bulkUpdate
CompletableFuture<Void> bulkUpdate(Collection<io.fluxzero.common.api.search.DocumentUpdate> updates, io.fluxzero.common.Guarantee guarantee) 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:
closein interfaceAutoCloseable
-