Provide query corrections for misspelled terms.
- Spell Check: Use
ftSpellcheck(index, term) to get corrections. Use SpellCheckArgs to configure distance (Levenshtein distance), terms("include", "dictionary"), and dialect(QueryDialects.DIALECT2). - Dictionary Management: Manage custom dictionaries for spell checking using
ftDictadd(dict, terms...), ftDictdel(dict, term), and ftDictdump(dict) to retrieve all terms. - Synonym Management: Create synonym groups with
ftSynupdate(index, group, terms...). Use SynUpdateArgs.skipInitialScan() to avoid reindexing existing documents.
// Spell check
SpellCheckArgs<String, String> spellArgs = SpellCheckArgs.<String, String>builder()
.distance(2)
.terms("include", "dictionary")
.dialect(QueryDialects.DIALECT2)
.build();
List<SpellCheckResult<String>> results = search.ftSpellcheck("products-idx", "wireles hedphones", spellArgs);
// Dictionary management
search.ftDictadd("custom_dict", "smartphone", "tablet", "laptop");
List<String> terms = search.ftDictdump("custom_dict");
// Synonym management
search.ftSynupdate("products-idx", "group1", "phone", "smartphone", "mobile");
SynUpdateArgs synArgs = SynUpdateArgs.builder().skipInitialScan().build();
search.ftSynupdate("products-idx", "group1", synArgs, "phone", "smartphone", "mobile", "cellphone");