Class DefaultDocumentStore.DefaultSearch<R>

java.lang.Object
io.fluxzero.sdk.persisting.search.DefaultDocumentStore.DefaultSearch<R>
All Implemented Interfaces:
Search<R>
Direct Known Subclasses:
DefaultDocumentStore.DefaultGraphSearch
Enclosing class:
DefaultDocumentStore

protected class DefaultDocumentStore.DefaultSearch<R> extends Object implements Search<R>
  • Field Details

    • graphComposition

      protected io.fluxzero.common.api.search.ModelGraphComposition graphComposition
    • graphPathOverrides

      protected List<io.fluxzero.common.api.modeling.ModelGraphPathOverride> graphPathOverrides
  • Constructor Details

    • DefaultSearch

      protected DefaultSearch()
  • Method Details

    • since

      public Search<R> since(Instant start, boolean inclusive)
      Description copied from interface: Search
      Filters documents with timestamps since the given start time.
      Specified by:
      since in interface Search<R>
      Parameters:
      inclusive - whether the start boundary is inclusive
    • before

      public Search<R> before(Instant end, boolean inclusive)
      Description copied from interface: Search
      Filters documents with timestamps before the given time.
      Specified by:
      before in interface Search<R>
      Parameters:
      inclusive - whether the end boundary is inclusive
    • inPeriod

      public Search<R> inPeriod(Instant start, boolean startInclusive, Instant end, boolean endInclusive)
      Description copied from interface: Search
      Filters documents within a specified time range.
      Specified by:
      inPeriod in interface Search<R>
    • constraint

      public Search<R> constraint(io.fluxzero.common.api.search.Constraint... constraints)
      Description copied from interface: Search
      Adds one or more custom constraints to the search using a logical AND.
      Specified by:
      constraint in interface Search<R>
    • relation

      public Search<R> relation(io.fluxzero.common.api.search.ModelRelationConstraint... constraints)
      Description copied from interface: Search
      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.

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

      Specified by:
      relation in interface Search<R>
    • sortByTimestamp

      public Search<R> sortByTimestamp(boolean descending)
      Description copied from interface: Search
      Sorts results by timestamp.
      Specified by:
      sortByTimestamp in interface Search<R>
      Parameters:
      descending - whether to sort in descending order
    • sortByScore

      public Search<R> sortByScore()
      Description copied from interface: Search
      Sorts results by full-text relevance score.
      Specified by:
      sortByScore in interface Search<R>
    • sortBy

      public Search<R> sortBy(String path, boolean descending)
      Description copied from interface: Search
      Sorts results by a field, with control over the sort direction.
      Specified by:
      sortBy in interface Search<R>
    • exclude

      public Search<R> exclude(String... paths)
      Description copied from interface: Search
      Excludes specific fields from the returned documents.
      Specified by:
      exclude in interface Search<R>
    • includeOnly

      public Search<R> includeOnly(String... paths)
      Description copied from interface: Search
      Includes only the specified fields in the returned documents.
      Specified by:
      includeOnly in interface Search<R>
    • skip

      public Search<R> skip(Integer n)
      Description copied from interface: Search
      Skips the first N results.
      Specified by:
      skip in interface Search<R>
    • streamHits

      public Stream<SearchHit<R>> streamHits()
      Description copied from interface: Search
      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.
      Specified by:
      streamHits in interface Search<R>
    • streamHits

      public Stream<SearchHit<R>> streamHits(int fetchSize)
      Description copied from interface: Search
      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.
      Specified by:
      streamHits in interface Search<R>
    • streamHits

      public <T> Stream<SearchHit<T>> streamHits(Class<T> type)
      Description copied from interface: Search
      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.
      Specified by:
      streamHits in interface Search<R>
    • streamHits

      public <T> Stream<SearchHit<T>> streamHits(Class<T> type, int fetchSize)
      Description copied from interface: Search
      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.
      Specified by:
      streamHits in interface Search<R>
    • fetch

      public List<R> fetch(int maxSize)
      Description copied from interface: Search
      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.
      Specified by:
      fetch in interface Search<R>
    • fetch

      public <T> List<T> fetch(int maxSize, Class<T> type)
      Description copied from interface: Search
      Fetches up to the given number of documents and deserializes them to the specified type.
      Specified by:
      fetch in interface Search<R>
    • fetchAsync

      public CompletableFuture<List<R>> fetchAsync(int maxSize)
      Description copied from interface: Search
      Asynchronously fetches up to the given number of matching documents and deserializes them to the stored type.

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

      Specified by:
      fetchAsync in interface Search<R>
      Parameters:
      maxSize - the maximum number of matching documents to fetch
      Returns:
      a future containing the deserialized search results
    • fetchAsync

      public <T> CompletableFuture<List<T>> fetchAsync(int maxSize, Class<T> type)
      Description copied from interface: Search
      Asynchronously fetches up to the given number of documents and deserializes them to the specified type.

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

      Specified by:
      fetchAsync in interface Search<R>
      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
    • fetchHitStream

      protected <T> Stream<SearchHit<T>> fetchHitStream(Integer maxSize, Class<T> type)
    • fetchHitStream

      protected <T> Stream<SearchHit<T>> fetchHitStream(Integer maxSize, Class<T> type, int fetchSize)
    • converter

      protected <T> Function<io.fluxzero.common.api.search.SerializedDocument, T> converter(Class<T> type)
    • convert

      protected Object convert(io.fluxzero.common.api.search.SerializedDocument document, Class<?> effectiveType)
    • defaultResultType

      protected Class<?> defaultResultType()
    • hasPathFilters

      protected boolean hasPathFilters()
    • fetchHistogram

      public io.fluxzero.common.api.search.SearchHistogram fetchHistogram(int resolution, int maxSize)
      Description copied from interface: Search
      Computes a histogram for the timestamp distribution of matching documents.
      Specified by:
      fetchHistogram in interface Search<R>
    • groupBy

      public GroupSearch groupBy(String... paths)
      Description copied from interface: Search
      Groups search results by field(s) and supports aggregations.
      Specified by:
      groupBy in interface Search<R>
    • facetStats

      public List<io.fluxzero.common.api.search.FacetStats> facetStats()
      Description copied from interface: Search
      Returns facet statistics for the current search.
      Specified by:
      facetStats in interface Search<R>
    • facetStatsAsync

      public CompletableFuture<List<io.fluxzero.common.api.search.FacetStats>> facetStatsAsync()
      Description copied from interface: Search
      Asynchronously returns facet statistics for the current search.

      This is the asynchronous counterpart of Search.facetStats().

      Specified by:
      facetStatsAsync in interface Search<R>
      Returns:
      a future containing facet value counts for the matching documents
    • delete

      public CompletableFuture<Void> delete(int batchSize)
      Description copied from interface: Search
      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.
      Specified by:
      delete in interface Search<R>
      Parameters:
      batchSize - requested delete batch size
      Returns:
      a future that completes when deletion has finished
    • move

      public CompletableFuture<Void> move(Object targetCollection)
      Description copied from interface: Search
      Moves all matching documents in the current search to the given collection.
      Specified by:
      move in interface Search<R>
      Parameters:
      targetCollection - the collection to move to