FTS search misses accented words: trigram tokenizer without remove_diacritics
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Find where the two FTS5 tables are created (search the codebase for tokenize='trigram' in the schema definitions for observations_fts and prompts_fts) and add remove_diacritics 1. Then add an index-rebuild path for existing stores, e.g. the INSERT INTO observations_fts(observations_fts) VALUES('rebuild') command the issue suggests. Verify with the SQL repro from the issue and any existing search tests; done means accented and unaccented queries both match.
Written by the indexing model from the issue text.
Description
Problem
mem_search does not fold accents. In languages that use diacritics (Spanish, French, Portuguese…), a query without the accent misses memories that contain it, and the other way round. People often type without accents, so these misses are frequent.
Example from a real store (engram 3.6.0, SQLite 3.50.4): a memory titled «resumen del vídeo de Fazt» is not found by mem_search "video".
Cause
Both FTS tables are created with tokenize='trigram':
CREATE VIRTUAL TABLE observations_fts USING fts5(title, content, tool_name, type, project, topic_key,
tokenize='trigram', content='observations', content_rowid='id');
CREATE VIRTUAL TABLE prompts_fts USING fts5(content, project,
tokenize='trigram', content='user_prompts', content_rowid='id');
Minimal reproduction (SQLite 3.50.4)
CREATE VIRTUAL TABLE t USING fts5(x, tokenize='trigram');
INSERT INTO t VALUES ('resumen del vídeo de Fazt');
SELECT count(*) FROM t WHERE t MATCH 'video'; -- 0
CREATE VIRTUAL TABLE t2 USING fts5(x, tokenize='trigram remove_diacritics 1');
INSERT INTO t2 VALUES ('resumen del vídeo de Fazt');
SELECT count(*) FROM t2 WHERE t2 MATCH 'video'; -- 1
Proposed fix
Create both tables with tokenize='trigram remove_diacritics 1' (available since SQLite 3.45), then rebuild the index for existing stores, for example with INSERT INTO observations_fts(observations_fts) VALUES('rebuild') after recreating the table. The change keeps substring matching and only folds diacritics.
Workaround today
Searching twice, once with and once without the accent.
- Dominant language
- Go
- Stars
- 7.1k
- Forks
- 729
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 268
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Gentleman-Programming/engram
-
status:needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Gentleman-Programming/engram#2065 · 1 comment ·
Maintainers usually reply within 1 day
-
feat(cli): run engram serve in the background as a daemon PR #2229Possibly taken @carolitascl claimed this 1 day ago. Openstatus:needs-review type:feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Gentleman-Programming/engram#2228 · 1 comment ·
Maintainers usually reply within 1 day
-
status:needs-review type:feature
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Gentleman-Programming/engram#2203 · 1 comment ·
Maintainers usually reply within 1 day
-
feat(store): reduce isolated test fixture startup costPossibly taken @dnlrsls claimed this 4 days ago. Openstatus:approved type:feature
Gentleman-Programming/engram#2202 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
status:needs-review type:question
Difficulty 5/5 Over a week Newbie friendliness 20/100
Gentleman-Programming/engram#2201 · 3 comments ·
Maintainers usually reply within 1 day
All issues in Gentleman-Programming/engram
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Schema validation is skipped when a transaction is invoked with a lowercase first letterPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
cmd/ebitenmobile: multi-language bindings run the complete generator twicePossibly taken @kumagi claimed this today. Openos:macos performance
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hajimehoshi/ebiten#4011 · 1 comment ·
Maintainers usually reply within 1 day
-
agent-butler-finding chore
Difficulty 1/5 Under an hour Newbie friendliness 78/100
jordansmall/spindrift#6318 ·
Maintainers usually reply within 1 day