Why does a SEARCH or MTREE index fail on SurrealDB 3?
SEARCH or MTREE index
Warning: the statement succeeds, then writes fail, access changes, or the table is held up.
What happens
Observed on SurrealDB 3.0.2: DEFINE INDEX ... SEARCH ANALYZER and ... MTREE DIMENSION are parse errors; FULLTEXT ANALYZER and HNSW are accepted.
Why it is dangerous on a populated table
Table size does not change this one: on SurrealDB 3 the file does not parse, so nothing in it runs, in any environment.
Fires on
DEFINE INDEX post_body ON TABLE post FIELDS body SEARCH ANALYZER simple BM25 CONCURRENTLY;The safe pattern
Use FULLTEXT ANALYZER for full-text indexes and HNSW for vector indexes.
DEFINE INDEX post_body ON TABLE post FIELDS body FULLTEXT ANALYZER simple BM25 CONCURRENTLY;Fixtures
The rule ships with these files and the test suite runs them on every change: the first set must fire, the second must stay silent.
Fires (2)
DEFINE INDEX doc_embedding ON TABLE doc FIELDS embedding MTREE DIMENSION 768 DIST COSINE CONCURRENTLY;DEFINE INDEX post_body ON TABLE post FIELDS body SEARCH ANALYZER simple BM25 CONCURRENTLY;Stays silent (2)
DEFINE INDEX post_body ON TABLE post FIELDS body FULLTEXT ANALYZER simple BM25 CONCURRENTLY;DEFINE INDEX doc_embedding ON TABLE doc FIELDS embedding HNSW DIMENSION 768 DIST COSINE CONCURRENTLY;How to check locally
SurrealDB support is in beta: this rule runs locally in the free CLI over .surql migrations, static only, and not in the hosted service yet. No install, nothing leaves your machine:
npx bolvrk check migration.surql --engine=surrealdb