ftsTerm function
Prepares a String for use as an extended FTS token.
This function replaces sequences of characters that do not match reFtsTermToken with ftsTermJoiner. The resulting token can be used as an indivisible unit in strings assigned to FTS fields and in FTS queries. It is "extended" because it can contain tokenCategories characters, which include the P and S categories in addition to the standard L, N, and Co categories. Possible uses for such tokens include identifiers and tags.
The ll parameter controls whether to perform additional checks on the
input string and how to react in the case of a failed check:
- if
llisLevel.OFF, no checks will be performed; - if
llisnull, an Error will be thrown on a failed check; - otherwise, on a failed check, a message will be logged at the
lllevel, which defaults toLevel.WARNING.
See also: ftsText.
Implementation
String ftsTerm(String string, [Level? ll = Level.WARNING]) {
if (ll != Level.OFF && string.contains(ftsTermJoiner)) {
String msg = "ftsTerm: \"$string\" contains ftsTermJoiner";
if (ll != null)
log.log(ll, msg);
else
throw StateError(msg);
}
var tokens = reFtsTermToken.allMatches(string).map((var m) => m.group(0)!);
return tokens.join(ftsTermJoiner);
}