Skip to content

like

relationalai.semantics.std.strings
like(s: StringValue, pattern: StringValue) -> Expression

Check whether s matches the SQL LIKE pattern pattern.

  • s

    (StringValue) - The string to match against.
  • pattern

    (StringValue) - The SQL LIKE pattern (% for wildcard, _ for single character).
  • Expression - An Expression that evaluates to true if s matches the pattern.

Match strings using SQL LIKE patterns:

>>> select(Brand.name).where(strings.like(Brand.name, r"Mc%"))
>>> select(Brand.name).where(strings.like(Brand.name, r"%est%"))
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Use advanced reasoning > Rules-based reasoning
        └──  Work with strings
            └──  Filter facts with text conditions