manticoresoftware / manticoresoftware/manticoresearch

make levenshtein() multibyte safe

Open
#640 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12k
Forks
642
Avg merge
3d 12h
Merged PRs (30d)
47

Description

levenshtein() seems to be not multibyte safe:

```sql
mysql> select levenshtein('п', 'п');
-------------------------
| levenshtein('п', 'п') |
-------------------------
| 0 |
-------------------------
1 row in set (0.00 sec)

mysql> select levenshtein('п', 'б');
-------------------------
| levenshtein('п', 'б') |
-------------------------
| 1 |
-------------------------
1 row in set (0.00 sec)

mysql> select levenshtein('п', 'р');
-------------------------
| levenshtein('п', 'р') |
-------------------------
| 2 |
-------------------------
1 row in set (0.00 sec)
```

It's not uncommon, e.g. in php it works similarly, but in Manticore as a database with rich full-text capabilities it makes sense to make it multibyte safe.

Related thread on forum https://forum.manticoresearch.com/t/levenshtein/878

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported SQL levenshtein() examples with multibyte characters and locating the function's implementation in the C++ codebase. Done means the function compares multibyte characters safely and produces the expected character-level edit distances for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.