Skip to content

fix(fts): export ignore_pattern, tokenizer and jieba_dict_dir - #125

Open
zahariash wants to merge 1 commit into
LadybugDB:mainfrom
zahariash:fix/fts-export-options
Open

zahariash wants to merge 1 commit into
LadybugDB:mainfrom
zahariash:fix/fts-export-options

Conversation

@zahariash

Copy link
Copy Markdown

This work was produced with the help of language models.

Fixes #120.

EXPORT DATABASE wrote each FTS index to index.cypher with only stemmer and stopWords, so IMPORT DATABASE created it with the default ignore_pattern and tokenizer: a jieba index came back with the simple tokenizer, a custom pattern as the default one, and queries and rows inserted after the import were normalized differently from the rows built from the exported macro.

Fix. toCypher writes ignore_pattern, tokenizer and jieba_dict_dir when they differ from their defaults, so index.cypher and the SHOW_INDEXES definition of a default index do not change. Every option value is escaped for a single-quoted Cypher literal; the helper moves to FTSUtils::escapeCypherString, shared with CREATE_FTS_INDEX, where it now also covers the stopwords path, which broke on a path containing a quote. This overlaps #124 in create_fts_index.cpp; whichever lands second gets rebased.

Tests. export_options.test exports an index with ignore_pattern := '[!]+' and a jieba index, imports them into a fresh database, finds 12345 and 北京清华, then inserts a row and finds it with a jieba query, which checks the imported index entry as well as the macro; a second case uses a stopwords file whose path contains a quote. Both fail on main and pass here. FTS extension tests: no new failures.

EXPORT DATABASE wrote each FTS index to index.cypher with only stemmer
and stopWords, so IMPORT DATABASE created an index with the default
ignore_pattern and tokenizer: queries and rows inserted after the import
were normalized differently from the rows built from the exported macro.
toCypher now writes the options that differ from their defaults, so
exports of default indexes do not change, and escapes every option value.
The escaping helper moves to FTSUtils and now also covers the stopwords
path in CREATE_FTS_INDEX, which broke on a path containing a quote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: EXPORT DATABASE drops ignore_pattern, tokenizer and jieba_dict_dir from FTS indexes

1 participant