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)
| 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. |