Skip to content

Browser rejects CREATE VECTOR INDEX with a syntax error: grammar lacks VECTOR keyword and OPTIONS clause #2058

Description

@dragnot

Summary

The browser rejects valid CREATE VECTOR INDEX statements with a client side Syntax error before the query is ever sent to the server. The same query succeeds against FalkorDB via redis-cli and via the Python client, so this is a browser grammar gap rather than a server limitation.

Reproduction

Run this in the browser query editor:

CREATE VECTOR INDEX FOR (u:User) ON (u.hdc_index_2048)
OPTIONS { dimension: 2048, similarityFunction: 'cosine' }

Result: Syntax error reported by the editor.

The identical query via redis-cli succeeds:

$ redis-cli GRAPH.QUERY vec_idx_test "CREATE VECTOR INDEX FOR (u:User) ON (u.hdc_index_2048) OPTIONS { dimension: 2048, similarityFunction: 'cosine' }"
Indices created: 1
Query internal execution time: 8.280917 milliseconds

Verified the index is fully functional afterwards: CALL db.indexes() reports OPERATIONAL, 2048 dimension vectors insert correctly with vecf32(), and db.idx.vector.queryNodes returns correctly ranked KNN results.

Tested against FalkorDB graph module 42003.

Root cause

lib/falkordb-cypher/generated/.grammar-src/Cypher.g4 lines 50 to 53:

oC_CreateIndex
           :  CREATE SP ( FULLTEXT SP )? INDEX SP?
              ( ( FOR SP? oC_IndexEntity SP? ON SP? oC_IndexProperties )
                | ( ON SP? ':' SP? oC_LabelName SP? oC_IndexProperties ) ) ;

Two gaps:

  1. No VECTOR keyword. The rule accepts an optional FULLTEXT qualifier only. There is no VECTOR token defined anywhere in the grammar (grep -c "^VECTOR" Cypher.g4 returns 0), so CREATE VECTOR INDEX cannot parse.
  2. No OPTIONS { ... } clause. The rule ends after oC_IndexProperties, so even if VECTOR were accepted, the trailing options map would still fail to parse. OPTIONS is required for vector indexes since dimension and similarityFunction are mandatory.

oC_DropIndex at lines 55 to 58 has the identical shape, so DROP VECTOR INDEX is affected the same way.

Worth noting the spec file already knows about vector search at the procedure level. lib/falkordb-cypher/falkordbSpec.ts lists db.idx.vector.queryNodes and db.idx.vector.queryRelationships, so querying a vector index is supported while creating one is not.

Suggested fix

Add a VECTOR lexer token, allow it as an alternative to FULLTEXT in both oC_CreateIndex and oC_DropIndex, and add an optional OPTIONS map clause. Roughly:

oC_CreateIndex
           :  CREATE SP ( ( FULLTEXT | VECTOR ) SP )? INDEX SP?
              ( ( FOR SP? oC_IndexEntity SP? ON SP? oC_IndexProperties )
                | ( ON SP? ':' SP? oC_LabelName SP? oC_IndexProperties ) )
              ( SP? OPTIONS SP? oC_MapLiteral )? ;

VECTOR and OPTIONS will also need adding to the non reserved keyword list around line 737, alongside the existing INDEX and FULLTEXT entries, so they remain usable as identifiers.

The parser is ANTLR generated, so generated/CypherParser.ts and generated/CypherLexer.ts need regenerating from the grammar source.

Impact

Vector indexes cannot be created from the browser at all. Users have to drop to redis-cli or a client library, which is a poor experience for anyone evaluating vector or GraphRAG capabilities in the UI.

Environment

  • Repo branch: staging
  • FalkorDB graph module: 42003
  • Browser: FalkorDB Browser on port 3000

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions