Interface Search<R>

Type Parameters:
R - the default result type returned by terminal operations without an explicit class. Class-based searches establish this type automatically; dynamic collection names can use an explicit type witness at the search entry point.
All Known Implementing Classes:
DefaultDocumentStore.DefaultGraphSearch, DefaultDocumentStore.DefaultSearch

public interface Search<R>
Fluent interface for building and executing document search queries in Fluxzero.

A Search instance is typically obtained via Fluxzero.search(DocumentType.class) or Fluxzero.<DocumentType>search("collectionName") and can be configured using a combination of time-based constraints, field constraints, sorting rules, pagination, and content selection.

The search is only executed when a terminal operation like fetch(...) or stream() is invoked.

Supported operations include:

Example usage:

List<MyDocument> results = Fluxzero.search(MyDocument.class)
    .inLast(Duration.ofDays(30))
    .match("searchTerm", "title", "description")
    .sortByTimestamp(true)
    .fetch(50);
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default number of records to fetch in a single batch during search operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Map<String, io.fluxzero.common.api.search.DocumentStats.FieldStats>
    aggregate(String... fields)
    Returns field statistics for one or more fields.
    default CompletableFuture<Map<String, io.fluxzero.common.api.search.DocumentStats.FieldStats>>
    Asynchronously returns field statistics for one or more fields.
    default Search<R>
    all(io.fluxzero.common.api.search.Constraint... constraints)
    Combines multiple constraints using a logical AND.
    default Search<R>
    any(io.fluxzero.common.api.search.Constraint... constraints)
    Combines multiple constraints using a logical OR.
    default Search<R>
    anyExist(String... paths)
    Constrains the search to documents that have any of the given paths.
    default Search<R>
    atLeast(Number min, String path)
    Adds a lower-bound constraint for a field.
    default Search<R>
    before(Instant endExclusive)
    Filters documents with timestamps strictly before the given end time.
    before(Instant end, boolean inclusive)
    Filters documents with timestamps before the given time.
    default Search<R>
    before(LocalDate endInclusive)
    Filters and returns search results that occur before the specified end date, inclusive.
    default Search<R>
    Filters out documents older than the given duration.
    default Search<R>
    below(Number max, String path)
    Adds an upper-bound constraint for a field.
    default Search<R>
    between(Number min, Number maxExclusive, String path)
    Adds a numeric range constraint.
    constraint(io.fluxzero.common.api.search.Constraint... constraints)
    Adds one or more custom constraints to the search using a logical AND.
    default Long
    Returns the number of matching documents.
    Asynchronously returns the number of matching documents.
    Deletes all matching documents in the current search.
    delete(int batchSize)
    Deletes all matching documents in the current search, using the requested batch size to control how many documents are removed by each delete statement.
    exclude(String... paths)
    Excludes specific fields from the returned documents.
    List<io.fluxzero.common.api.search.FacetStats>
    Returns facet statistics for the current search.
    CompletableFuture<List<io.fluxzero.common.api.search.FacetStats>>
    Asynchronously returns facet statistics for the current search.
    fetch(int maxSize)
    Fetches up to the given number of matching documents and deserializes them to the stored type.
    <T> List<T>
    fetch(int maxSize, Class<T> type)
    Fetches up to the given number of documents and deserializes them to the specified type.
    default List<R>
    Fetches all matching documents and deserializes each to its stored type.
    default <T> List<T>
    fetchAll(Class<T> type)
    Fetches all matching documents and deserializes them to the specified type.
    fetchAsync(int maxSize)
    Asynchronously fetches up to the given number of matching documents and deserializes them to the stored type.
    fetchAsync(int maxSize, Class<T> type)
    Asynchronously fetches up to the given number of documents and deserializes them to the specified type.
    default Optional<R>
    Fetches the first matching document if available and deserializes it to the stored type.
    default <T> Optional<T>
    fetchFirst(Class<T> type)
    Fetches the first matching document if available and deserializes it as an optional value of the specified type.
    default R
    Fetches the first matching document if available and deserializes it to the stored type.
    default <T> T
    Fetches the first matching document if available and deserializes it to the specified type.
    io.fluxzero.common.api.search.SearchHistogram
    fetchHistogram(int resolution, int maxSize)
    Computes a histogram for the timestamp distribution of matching documents.
    groupBy(String... paths)
    Groups search results by field(s) and supports aggregations.
    includeOnly(String... paths)
    Includes only the specified fields in the returned documents.
    default Search<R>
    inLast(Duration period)
    Filters documents within the last given duration (e.g., last 7 days).
    inPeriod(Instant start, boolean startInclusive, Instant end, boolean endInclusive)
    Filters documents within a specified time range.
    default Search<R>
    inPeriod(Instant start, Instant endExclusive)
    Filters documents within the given time range.
    default Search<R>
    inPeriod(LocalDate start, LocalDate endInclusive)
    Filters the search results to include only those within the specified date range.
    default Search<R>
    lookAhead(String phrase, String... paths)
    Adds a full-text lookahead constraint using the specified phrase.
    default Search<R>
    match(Object constraint, boolean strict, String... paths)
    Adds a match constraint, optionally enforcing strict equality.
    default Search<R>
    match(Object constraint, String... paths)
    Adds an equality match constraint for the given value across one or more paths.
    default Search<R>
    matchFacet(String name, Object value)
    Matches the value of a named facet.
    default Search<R>
    Matches a metadata key to a value.
    move(Object targetCollection)
    Moves all matching documents in the current search to the given collection.
    default Search<R>
    not(io.fluxzero.common.api.search.Constraint constraint)
    Negates a constraint using a logical NOT.
    default Search<R>
    query(String phrase, String... paths)
    Adds a full-text search constraint for the given phrase.
    default Search<R>
    relation(io.fluxzero.common.api.search.ModelRelationConstraint... constraints)
    Adds advanced current-state model relationship constraints using logical AND.
    default Search<R>
    since(Instant start)
    Filters documents with timestamps since the given start time (inclusive).
    since(Instant start, boolean inclusive)
    Filters documents with timestamps since the given start time.
    default Search<R>
    Initiates a search operation from a specified start date.
    Skips the first N results.
    default Search<R>
    sortBy(String path)
    Sorts results by a specific document field.
    sortBy(String path, boolean descending)
    Sorts results by a field, with control over the sort direction.
    default Search<R>
    sortBy(String path, boolean descending, Search.NullOrder nullOrder)
    Sorts results by a field, with control over both sort direction and null ordering.
    default Search<R>
    sortBy(String path, Search.NullOrder nullOrder)
    Sorts results by a specific document field, with explicit null ordering.
    Sorts results by full-text relevance score.
    default Search<R>
    Sorts results by timestamp in ascending order.
    sortByTimestamp(boolean descending)
    Sorts results by timestamp.
    default Search<R>
    sortByTimestamp(boolean descending, Search.NullOrder nullOrder)
    Sorts results by timestamp, with explicit null ordering.
    default Stream<R>
    Streams matching values, deserializing each to the stored type.
    default Stream<R>
    stream(int fetchSize)
    Streams matching values, deserializing each to the stored type.
    default <T> Stream<T>
    stream(Class<T> type)
    Streams matching values, deserializing each to the specified type.
    default <T> Stream<T>
    stream(Class<T> type, int fetchSize)
    Streams matching values, deserializing each to the specified type.
    Streams raw search hits (document + metadata).
    streamHits(int fetchSize)
    Streams raw search hits (document + metadata).
    <T> Stream<SearchHit<T>>
    streamHits(Class<T> type)
    Streams raw search hits (document + metadata).
    <T> Stream<SearchHit<T>>
    streamHits(Class<T> type, int fetchSize)
    Streams raw search hits (document + metadata).
    default <T> InputStream
    toInputStream(Class<T> type, io.fluxzero.common.ThrowingBiConsumer<T, OutputStream> writer)
    Streams matching values of the specified type as a lazily populated InputStream.
    default <T> InputStream
    toInputStream(Class<T> type, io.fluxzero.common.ThrowingBiConsumer<T, OutputStream> writer, int fetchSize)
    Streams matching values of the specified type as a lazily populated InputStream, fetching documents in batches of fetchSize.
    default InputStream
    Streams matching values as NDJSON using the stored document types and the default fetch size.
    default <T> InputStream
    toUtf8InputStream(Class<T> type, io.fluxzero.common.ThrowingFunction<T,String> mapper)
    Streams matching values of the specified type as a lazily populated UTF-8 InputStream.
    default <T> InputStream
    toUtf8InputStream(Class<T> type, io.fluxzero.common.ThrowingFunction<T,String> mapper, int fetchSize)
    Streams matching values of the specified type as a lazily populated UTF-8 InputStream, fetching documents in batches of fetchSize.
    default Search<R>
    whereAncestor(Graph<?> ancestor)
    Requires the supplied existing Model graph to be an ancestor at any supported depth.
    default Search<R>
    whereAncestor(Graph<?> ancestor, int minDepth, int maxDepth)
    Requires the supplied existing Model graph to be an ancestor within the given depth range.
    default Search<R>
    whereAncestor(Id<?> ancestorId)
    Requires an ancestor with the supplied typed identity at any supported depth.
    default Search<R>
    whereAncestor(Id<?> ancestorId, int minDepth, int maxDepth)
    Requires an ancestor with the supplied typed identity within the given depth range.
    default Search<R>
    whereAncestor(Object collection, int minDepth, int maxDepth, io.fluxzero.common.api.search.Constraint... constraints)
    Requires an ancestor document within the supplied depth range to match the document constraints.
    default Search<R>
    whereAncestor(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
    Requires an ancestor document at any supported depth to match the supplied document constraints.
    default Search<R>
    whereAncestor(Object ancestorId, Class<?> ancestorType)
    Requires an ancestor with the supplied functional identity and Model type at any supported depth.
    default Search<R>
    whereAncestor(Object ancestorId, Class<?> ancestorType, int minDepth, int maxDepth)
    Requires an ancestor with the supplied functional identity and Model type within the given depth range.
    default Search<R>
    whereChild(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
    Requires a directly related child document to match the supplied document constraints.
    default Search<R>
    whereDescendant(Object collection, int minDepth, int maxDepth, io.fluxzero.common.api.search.Constraint... constraints)
    Requires a descendant document within the supplied depth range to match the document constraints.
    default Search<R>
    whereDescendant(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
    Requires a descendant document at any supported depth to match the supplied document constraints.
    default Search<R>
    whereParent(Graph<?> parent)
    Requires the supplied existing Model graph to be the direct parent.
    default Search<R>
    whereParent(Id<?> parentId)
    Requires a direct parent with the supplied typed identity.
    default Search<R>
    whereParent(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
    Requires a directly related parent document to match the supplied document constraints.
    default Search<R>
    whereParent(Object parentId, Class<?> parentType)
    Requires a direct parent with the supplied functional identity and Model type.
  • Field Details

    • defaultFetchSize

      static final int defaultFetchSize
      The default number of records to fetch in a single batch during search operations. Primarily used in streaming and batch-fetching methods to control the size of each data retrieval operation.

      A higher value increases the data fetch per operation, potentially reducing the number of retrievals but consuming more memory. A lower value minimizes memory usage but may require more network or database calls for large datasets.

      See Also:
  • Method Details

    • since

      default Search<R> since(Instant start)
      Filters documents with timestamps since the given start time (inclusive).
    • since

      Search<R> since(Instant start, boolean inclusive)
      Filters documents with timestamps since the given start time.
      Parameters:
      inclusive - whether the start boundary is inclusive
    • since

      default Search<R> since(LocalDate start)
      Initiates a search operation from a specified start date.
      Parameters:
      start - the start date from which the search is to be started.
      Returns:
      a Search object initialized with the converted instant from the specified start date.
    • before

      default Search<R> before(Instant endExclusive)
      Filters documents with timestamps strictly before the given end time.
    • before

      Search<R> before(Instant end, boolean inclusive)
      Filters documents with timestamps before the given time.
      Parameters:
      inclusive - whether the end boundary is inclusive
    • before

      default Search<R> before(LocalDate endInclusive)
      Filters and returns search results that occur before the specified end date, inclusive.
      Parameters:
      endInclusive - the end date to compare with, inclusive
      Returns:
      a Search object containing results that occur before the specified end date
    • beforeLast

      default Search<R> beforeLast(Duration period)
      Filters out documents older than the given duration.
    • inLast

      default Search<R> inLast(Duration period)
      Filters documents within the last given duration (e.g., last 7 days).
    • inPeriod

      default Search<R> inPeriod(Instant start, Instant endExclusive)
      Filters documents within the given time range.
    • inPeriod

      Search<R> inPeriod(Instant start, boolean startInclusive, Instant end, boolean endInclusive)
      Filters documents within a specified time range.
    • inPeriod

      default Search<R> inPeriod(LocalDate start, LocalDate endInclusive)
      Filters the search results to include only those within the specified date range.
    • lookAhead

      default Search<R> lookAhead(String phrase, String... paths)
      Adds a full-text lookahead constraint using the specified phrase.
    • query

      default Search<R> query(String phrase, String... paths)
      Adds a full-text search constraint for the given phrase.
    • match

      default Search<R> match(Object constraint, String... paths)
      Adds an equality match constraint for the given value across one or more paths.
    • match

      default Search<R> match(Object constraint, boolean strict, String... paths)
      Adds a match constraint, optionally enforcing strict equality.
    • matchFacet

      default Search<R> matchFacet(String name, Object value)
      Matches the value of a named facet.
    • matchMetadata

      default Search<R> matchMetadata(String key, Object value)
      Matches a metadata key to a value.
    • anyExist

      default Search<R> anyExist(String... paths)
      Constrains the search to documents that have any of the given paths.
    • atLeast

      default Search<R> atLeast(Number min, String path)
      Adds a lower-bound constraint for a field.
    • below

      default Search<R> below(Number max, String path)
      Adds an upper-bound constraint for a field.
    • between

      default Search<R> between(Number min, Number maxExclusive, String path)
      Adds a numeric range constraint.
    • all

      default Search<R> all(io.fluxzero.common.api.search.Constraint... constraints)
      Combines multiple constraints using a logical AND.
    • any

      default Search<R> any(io.fluxzero.common.api.search.Constraint... constraints)
      Combines multiple constraints using a logical OR.
    • not

      default Search<R> not(io.fluxzero.common.api.search.Constraint constraint)
      Negates a constraint using a logical NOT.
    • constraint

      Search<R> constraint(io.fluxzero.common.api.search.Constraint... constraints)
      Adds one or more custom constraints to the search using a logical AND.
    • whereParent

      default Search<R> whereParent(Id<?> parentId)
      Requires a direct parent with the supplied typed identity.

      Unlike the related-document overload, this selector starts directly from the parent's durable Model identity and therefore does not require the parent to maintain a current-state document.

    • whereParent

      default Search<R> whereParent(Object parentId, Class<?> parentType)
      Requires a direct parent with the supplied functional identity and Model type.

      Use this overload for identifiers that do not extend Id. The Model type supplies any configured @EntityId affixes needed to resolve its exact persisted identity.

    • whereParent

      default Search<R> whereParent(Graph<?> parent)
      Requires the supplied existing Model graph to be the direct parent.

      This overload is useful when the parent's persisted identity is scoped by one of its own parents.

    • whereParent

      default Search<R> whereParent(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
      Requires a directly related parent document to match the supplied document constraints.
    • whereAncestor

      default Search<R> whereAncestor(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
      Requires an ancestor document at any supported depth to match the supplied document constraints.
    • whereAncestor

      default Search<R> whereAncestor(Id<?> ancestorId)
      Requires an ancestor with the supplied typed identity at any supported depth.

      This selector uses only the durable Model relationship index; the ancestor does not need a current-state document or public search projection.

    • whereAncestor

      default Search<R> whereAncestor(Id<?> ancestorId, int minDepth, int maxDepth)
      Requires an ancestor with the supplied typed identity within the given depth range.
    • whereAncestor

      default Search<R> whereAncestor(Object ancestorId, Class<?> ancestorType)
      Requires an ancestor with the supplied functional identity and Model type at any supported depth.

      Use this overload for identifiers that do not extend Id.

    • whereAncestor

      default Search<R> whereAncestor(Graph<?> ancestor)
      Requires the supplied existing Model graph to be an ancestor at any supported depth.
    • whereAncestor

      default Search<R> whereAncestor(Graph<?> ancestor, int minDepth, int maxDepth)
      Requires the supplied existing Model graph to be an ancestor within the given depth range.
    • whereAncestor

      default Search<R> whereAncestor(Object ancestorId, Class<?> ancestorType, int minDepth, int maxDepth)
      Requires an ancestor with the supplied functional identity and Model type within the given depth range.

      The related Model itself is never loaded or searched. Models with parent-scoped primary identities cannot be resolved from a functional ID alone; use an exact persisted identity obtained from their Graph instead.

    • whereAncestor

      default Search<R> whereAncestor(Object collection, int minDepth, int maxDepth, io.fluxzero.common.api.search.Constraint... constraints)
      Requires an ancestor document within the supplied depth range to match the document constraints.
    • whereChild

      default Search<R> whereChild(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
      Requires a directly related child document to match the supplied document constraints.
    • whereDescendant

      default Search<R> whereDescendant(Object collection, io.fluxzero.common.api.search.Constraint... constraints)
      Requires a descendant document at any supported depth to match the supplied document constraints.
    • whereDescendant

      default Search<R> whereDescendant(Object collection, int minDepth, int maxDepth, io.fluxzero.common.api.search.Constraint... constraints)
      Requires a descendant document within the supplied depth range to match the document constraints.
    • relation

      default Search<R> relation(io.fluxzero.common.api.search.ModelRelationConstraint... constraints)
      Adds advanced current-state model relationship constraints using logical AND.

      Class-based related queries use the model's actual current-document collection. This includes the private, type-isolated collection of a model that participates in graph composition without maintaining a direct public document. Related documents are selected before relationship traversal and target search, so a selective child constraint does not require live composition of unrelated roots. Constraints with exact related model IDs skip related-document selection and can therefore start from an event-sourced Model that has no current document.

      Implementations that do not support independent-model graph search fail when this method is called.

    • sortByTimestamp

      default Search<R> sortByTimestamp()
      Sorts results by timestamp in ascending order.
    • sortByTimestamp

      Search<R> sortByTimestamp(boolean descending)
      Sorts results by timestamp.
      Parameters:
      descending - whether to sort in descending order
    • sortByTimestamp

      default Search<R> sortByTimestamp(boolean descending, Search.NullOrder nullOrder)
      Sorts results by timestamp, with explicit null ordering.
    • sortByScore

      Search<R> sortByScore()
      Sorts results by full-text relevance score.
    • sortBy

      default Search<R> sortBy(String path)
      Sorts results by a specific document field.
    • sortBy

      Search<R> sortBy(String path, boolean descending)
      Sorts results by a field, with control over the sort direction.
    • sortBy

      default Search<R> sortBy(String path, Search.NullOrder nullOrder)
      Sorts results by a specific document field, with explicit null ordering.
    • sortBy

      default Search<R> sortBy(String path, boolean descending, Search.NullOrder nullOrder)
      Sorts results by a field, with control over both sort direction and null ordering.
    • exclude

      Search<R> exclude(String... paths)
      Excludes specific fields from the returned documents.
    • includeOnly

      Search<R> includeOnly(String... paths)
      Includes only the specified fields in the returned documents.
    • skip

      Search<R> skip(Integer n)
      Skips the first N results.
    • fetch

      List<R> fetch(int maxSize)
      Fetches up to the given number of matching documents and deserializes them to the stored type. Returns the deserialized values as instances of type R.
    • fetchAsync

      default CompletableFuture<List<R>> fetchAsync(int maxSize)
      Asynchronously fetches up to the given number of matching documents and deserializes them to the stored type.

      This is the asynchronous counterpart of fetch(int). The returned future completes with a materialized list containing at most maxSize results.

      Parameters:
      maxSize - the maximum number of matching documents to fetch
      Returns:
      a future containing the deserialized search results
    • fetch

      <T> List<T> fetch(int maxSize, Class<T> type)
      Fetches up to the given number of documents and deserializes them to the specified type.
    • fetchAsync

      <T> CompletableFuture<List<T>> fetchAsync(int maxSize, Class<T> type)
      Asynchronously fetches up to the given number of documents and deserializes them to the specified type.

      This is the asynchronous counterpart of fetch(int, Class). Use this method when handling requests that can return a CompletableFuture; for very large result sets, prefer the streaming methods.

      Type Parameters:
      T - the expected result type
      Parameters:
      maxSize - the maximum number of matching documents to fetch
      type - the type to deserialize each document to
      Returns:
      a future containing the deserialized search results
    • fetchAll

      default List<R> fetchAll()
      Fetches all matching documents and deserializes each to its stored type. Returns the deserialized values as instances of type R.
    • fetchAll

      default <T> List<T> fetchAll(Class<T> type)
      Fetches all matching documents and deserializes them to the specified type.
    • fetchFirst

      default Optional<R> fetchFirst()
      Fetches the first matching document if available and deserializes it to the stored type. Returns the deserialized value as an optional instance of type R.
    • fetchFirst

      default <T> Optional<T> fetchFirst(Class<T> type)
      Fetches the first matching document if available and deserializes it as an optional value of the specified type.
    • fetchFirstOrNull

      default R fetchFirstOrNull()
      Fetches the first matching document if available and deserializes it to the stored type. Returns the deserialized value as an instance of type R.
    • fetchFirstOrNull

      default <T> T fetchFirstOrNull(Class<T> type)
      Fetches the first matching document if available and deserializes it to the specified type.
    • stream

      default Stream<R> stream()
      Streams matching values, deserializing each to the stored type. Documents will typically be fetched in batches from the backing store. For the default implementation, the fetch size is 10,000.
    • stream

      default Stream<R> stream(int fetchSize)
      Streams matching values, deserializing each to the stored type. Documents will be fetched in batches of size fetchSize from the backing store.
    • stream

      default <T> Stream<T> stream(Class<T> type)
      Streams matching values, deserializing each to the specified type. Documents will typically be fetched in batches from the backing store. For the default implementation, the fetch size is 10,000.
    • stream

      default <T> Stream<T> stream(Class<T> type, int fetchSize)
      Streams matching values, deserializing each to the specified type. Documents will be fetched in batches of size fetchSize from the backing store.
    • toUtf8InputStream

      default <T> InputStream toUtf8InputStream(Class<T> type, io.fluxzero.common.ThrowingFunction<T,String> mapper)
      Streams matching values of the specified type as a lazily populated UTF-8 InputStream.
    • toUtf8InputStream

      default <T> InputStream toUtf8InputStream(Class<T> type, io.fluxzero.common.ThrowingFunction<T,String> mapper, int fetchSize)
      Streams matching values of the specified type as a lazily populated UTF-8 InputStream, fetching documents in batches of fetchSize.
    • toInputStream

      default <T> InputStream toInputStream(Class<T> type, io.fluxzero.common.ThrowingBiConsumer<T, OutputStream> writer)
      Streams matching values of the specified type as a lazily populated InputStream.
    • toInputStream

      default <T> InputStream toInputStream(Class<T> type, io.fluxzero.common.ThrowingBiConsumer<T, OutputStream> writer, int fetchSize)
      Streams matching values of the specified type as a lazily populated InputStream, fetching documents in batches of fetchSize.
    • toNdjsonInputStream

      default InputStream toNdjsonInputStream()
      Streams matching values as NDJSON using the stored document types and the default fetch size.
    • streamHits

      Stream<SearchHit<R>> streamHits()
      Streams raw search hits (document + metadata). Documents will typically be fetched in batches from the backing store. For the default implementation, the fetch size is 10,000.
    • streamHits

      Stream<SearchHit<R>> streamHits(int fetchSize)
      Streams raw search hits (document + metadata). Documents will be fetched in batches of size fetchSize from the backing store. For the default implementation, the fetch size is 10,000.
    • streamHits

      <T> Stream<SearchHit<T>> streamHits(Class<T> type)
      Streams raw search hits (document + metadata). Documents will be fetched in batches of size fetchSize from the backing store. For the default implementation, the fetch size is 10,000.
    • streamHits

      <T> Stream<SearchHit<T>> streamHits(Class<T> type, int fetchSize)
      Streams raw search hits (document + metadata). Documents will be fetched in batches of size fetchSize from the backing store. For the default implementation, the fetch size is 10,000.
    • fetchHistogram

      io.fluxzero.common.api.search.SearchHistogram fetchHistogram(int resolution, int maxSize)
      Computes a histogram for the timestamp distribution of matching documents.
    • groupBy

      GroupSearch groupBy(String... paths)
      Groups search results by field(s) and supports aggregations.
    • count

      default Long count()
      Returns the number of matching documents.
    • countAsync

      default CompletableFuture<Long> countAsync()
      Asynchronously returns the number of matching documents.

      This is the asynchronous counterpart of count().

      Returns:
      a future containing the matching document count
    • aggregate

      default Map<String, io.fluxzero.common.api.search.DocumentStats.FieldStats> aggregate(String... fields)
      Returns field statistics for one or more fields.
    • aggregateAsync

      default CompletableFuture<Map<String, io.fluxzero.common.api.search.DocumentStats.FieldStats>> aggregateAsync(String... fields)
      Asynchronously returns field statistics for one or more fields.

      This is the asynchronous counterpart of aggregate(String...) and returns the statistics for the ungrouped result set.

      Parameters:
      fields - the fields to compute statistics for; omit fields to request the default count statistics
      Returns:
      a future containing field statistics keyed by field name
    • facetStats

      List<io.fluxzero.common.api.search.FacetStats> facetStats()
      Returns facet statistics for the current search.
    • facetStatsAsync

      CompletableFuture<List<io.fluxzero.common.api.search.FacetStats>> facetStatsAsync()
      Asynchronously returns facet statistics for the current search.

      This is the asynchronous counterpart of facetStats().

      Returns:
      a future containing facet value counts for the matching documents
    • delete

      default CompletableFuture<Void> delete()
      Deletes all matching documents in the current search.

      This is equivalent to calling delete(0), which lets the runtime choose the batch size.

    • delete

      CompletableFuture<Void> delete(int batchSize)
      Deletes all matching documents in the current search, using the requested batch size to control how many documents are removed by each delete statement.

      The batch size does not limit the total number of documents that are deleted. For a positive batch size, the runtime repeatedly selects and deletes at most that many matching documents until no matches remain. This keeps individual statements and their locks shorter, at the cost of executing multiple statements.

      • 0 lets the runtime choose its default batch size;
      • a positive value sets the maximum number of documents processed per batch;
      • a negative value requests deletion with one unbounded statement.
      Each batch may be committed independently. If a later batch fails, documents removed by earlier batches remain deleted. The returned future completes only after all matching documents have been processed, or completes exceptionally when a batch fails.
      Parameters:
      batchSize - requested delete batch size
      Returns:
      a future that completes when deletion has finished
    • move

      CompletableFuture<Void> move(Object targetCollection)
      Moves all matching documents in the current search to the given collection.
      Parameters:
      targetCollection - the collection to move to