Class SearchQuery

java.lang.Object
io.fluxcapacitor.common.api.search.SearchQuery

public class SearchQuery extends Object
A query for filtering documents in one or more search collections.

A SearchQuery is used to retrieve documents from the search index by applying a combination of time-based constraints, collection filters, and field-level constraints.

Example usage:


 SearchQuery query = SearchQuery.builder()
     .collection("complaints")
     .since(Instant.parse("2023-01-01T00:00:00Z"))
     .before(Instant.now())
     .constraint(BetweenConstraint.atLeast(2, "priority"))
     .build();
 

Fields

  • collections: List of collection names to search in (required).
  • since, before: Start and end timestamps to filter documents within a time window.
  • sinceExclusive, beforeInclusive: Control boundary inclusivity for time filtering.
  • constraints: A list of Constraint objects applied to fields within the document.

Validation

The query must include at least one collection. An exception is thrown if none are specified.
See Also:
  • Constructor Details

  • Method Details

    • getBefore

      public Instant getBefore()
    • matches

      public boolean matches(SerializedDocument d)
      Checks if the given serialized document matches the query's constraints and collection filters.
      Parameters:
      d - the serialized document to be checked; may be null. If null or if the collection of the document is not part of the query's collection filters, the method returns false.
      Returns:
      true if the document meets the constraints and collection filters of the query, false otherwise.