MCPcopy
hub / github.com/redis/redis-py / spellcheck

Method spellcheck

redis/commands/search/commands.py:1456–1482  ·  view source on GitHub ↗

Issue a spellcheck query Args: query: search query. distance: the maximal Levenshtein distance for spelling suggestions (default: 1, max: 4). include: specifies an inclusion custom dictionary. exclude: specifie

(self, query, distance=None, include=None, exclude=None)

Source from the content-addressed store, hash-verified

1454 )
1455
1456 def spellcheck(self, query, distance=None, include=None, exclude=None):
1457 """
1458 Issue a spellcheck query
1459
1460 Args:
1461
1462 query: search query.
1463 distance: the maximal Levenshtein distance for spelling
1464 suggestions (default: 1, max: 4).
1465 include: specifies an inclusion custom dictionary.
1466 exclude: specifies an exclusion custom dictionary.
1467
1468 For more information see `FT.SPELLCHECK <https://redis.io/commands/ft.spellcheck>`_.
1469 """ # noqa
1470 cmd = [SPELLCHECK_CMD, self.index_name, query]
1471 if distance:
1472 cmd.extend(["DISTANCE", distance])
1473
1474 if include:
1475 cmd.extend(["TERMS", "INCLUDE", include])
1476
1477 if exclude:
1478 cmd.extend(["TERMS", "EXCLUDE", exclude])
1479
1480 res = self.execute_command(*cmd)
1481
1482 return self._parse_results(SPELLCHECK_CMD, res)
1483
1484 def dict_add(self, name: str, *terms: List[str]):
1485 """Adds terms to a dictionary.

Callers 3

test_spell_checkMethod · 0.45
test_spell_checkMethod · 0.45

Calls 3

_parse_resultsMethod · 0.95
extendMethod · 0.45
execute_commandMethod · 0.45

Tested by 3

test_spell_checkMethod · 0.36
test_spell_checkMethod · 0.36