buildFtsQuery static method

String buildFtsQuery(
  1. String query, {
  2. int maxBytes = 262144,
})

Builds a sanitized FTS5 MATCH query from query tokens.

Each extracted token has embedded double quotes doubled and is wrapped in double quotes, then joined with OR.

Implementation

static String buildFtsQuery(String query, {int maxBytes = 262144}) {
  final String normalized = _normalizeText(query, maxBytes: maxBytes);
  final List<String> tokens = _extractTokens(normalized);
  if (tokens.isEmpty) {
    return '';
  }
  return tokens
      .map((String token) => '"${token.replaceAll('"', '""')}"')
      .join(' OR ');
}