tokenizeJson method Null safety
- Map<
String, dynamic> document, - {NGramRange? nGramRange,
- Iterable<
Zone> ? zones, - TokenizingStrategy strategy = TokenizingStrategy.terms}
override
Extracts tokens from the zones in a JSON document for use in
full-text search queries and indexes.
nGramRangeis the range of N-gram lengths to generate; andzonesis the collection of the names of the zones indocumentthat are to be tokenized.
Returns a List<Token>.
Implementation
@override
Future<List<Token>> tokenizeJson(Map<String, dynamic> document,
{NGramRange? nGramRange,
Iterable<Zone>? zones,
TokenizingStrategy strategy = TokenizingStrategy.terms}) async {
final tokens = <Token>[];
if (zones == null || zones.isEmpty) {
zones = document.keys;
}
zones = zones.toSet();
for (final zone in zones) {
final value = document[zone];
if (value != null) {
final source = value.toString();
if (source.isNotEmpty) {
tokens.addAll(await tokenize(source,
zone: zone, nGramRange: nGramRange, strategy: strategy));
}
}
}
return tokens;
}