Class LookAheadConstraint

java.lang.Object
io.fluxcapacitor.common.api.search.constraints.PathConstraint
io.fluxcapacitor.common.api.search.constraints.LookAheadConstraint
All Implemented Interfaces:
Constraint

public class LookAheadConstraint extends PathConstraint
A constraint that supports search-as-you-type functionality by matching terms or phrases that start with a given input string.

For example, the input "hat" will match documents containing terms like "hatter" or phrases like "the cat with the hat".

The constraint delegates matching to an equivalent ContainsConstraint created via Constraint.decompose().

If no paths are provided, the constraint will match across all paths in the document.

See Also:
  • Constructor Details

    • LookAheadConstraint

      public LookAheadConstraint()
  • Method Details

    • lookAhead

      public static Constraint lookAhead(String lookAhead, String... paths)
      Creates a LookAheadConstraint that matches any terms or phrases starting with the given input string.

      If the input is blank or null, this returns a NoOpConstraint.

      Parameters:
      lookAhead - the search prefix
      paths - optional field paths to restrict the search to
      Returns:
      a LookAheadConstraint or NoOpConstraint
    • matches

      public boolean matches(Document document)
      Evaluates whether this constraint matches the given Document. This implementation delegates to the result of Constraint.decompose().
      Specified by:
      matches in interface Constraint
      Overrides:
      matches in class PathConstraint
      Parameters:
      document - the document to test
      Returns:
      true if the document matches, otherwise false
    • matches

      protected boolean matches(Document.Entry entry)
      Not supported for this constraint type, as this constraint relies on higher-level document decomposition.
      Specified by:
      matches in class PathConstraint
      Parameters:
      entry - the document entry to evaluate
      Returns:
      true if the entry satisfies the condition; false otherwise
      Throws:
      UnsupportedOperationException - always