← Back to Stormify Documentation

TextQuery

object TextQuery

Google-like boolean query parser and renderer for facet filters.

Grammar (default syntax):

  • foo bar — implicit AND

  • foo OR bar — OR (uppercase keyword)

  • -foo — NOT

  • "foo bar" — phrase (literal substring)

  • (foo OR bar) — grouping

  • foo*, *foo — LIKE prefix/suffix wildcard

  • NULL — SQL NULL match

Precedence: AND binds tighter than OR. Tokens are configurable via FilterSyntax.

Used internally by the default text converter. Custom Converter implementations can call parse to walk the AST directly.

Properties

Link copied to clipboard

Default token configuration — English Google-like syntax.

Functions

Link copied to clipboard
fun parse(input: String, syntax: FilterSyntax = defaultSyntax): TextNode?

Parses input into a TextNode AST, or returns null if empty/malformed. Respects input-length, token-count, and nesting-depth safety limits.

Link copied to clipboard
fun parseAndRender(input: String, column: String, dialect: SqlDialect, caseSensitive: Boolean, args: SqlArgsCollector, syntax: FilterSyntax = defaultSyntax): String?

Convenience combining parse + renderAst with the default LIKE atom renderer. Returns null for empty/malformed input.

Link copied to clipboard
fun renderAst(ast: TextNode, column: String, atomRenderer: (text: String, isPhrase: Boolean) -> String): String

Renders ast to SQL using a caller-supplied atomRenderer that handles TermNode and PhraseNode leaves. Boolean composition (AND/OR/NOT) and NullNode are emitted as standard SQL.