core/scripts/create-vector-indexes.cypher
Elias Stepanik 164e5a2f1d feat: add BullMQ space assignment, replace GDS cosine similarity, and make Trigger optional
- Implement space assignment queue and worker for BullMQ
- Add native Cypher cosine similarity function to replace GDS dependency
- Make Trigger.dev environment variables optional (only required when QUEUE_PROVIDER=trigger)
- Add EMBEDDING_MODEL_SIZE configuration for vector index management
- Update vector search queries to use native Neo4j vector search with score
- Add Neo4j utility scripts for index management and troubleshooting
- Update documentation with embedding model configuration and vector index recreation steps
2025-10-24 20:38:52 +00:00

23 lines
1.2 KiB
Plaintext

// Drop existing vector indexes if they exist (to handle dimension mismatches)
DROP INDEX entity_embedding IF EXISTS;
DROP INDEX statement_embedding IF EXISTS;
DROP INDEX episode_embedding IF EXISTS;
// Create vector indexes with 1536 dimensions (for text-embedding-3-small)
// Change the vector.dimensions value if using a different embedding model:
// - text-embedding-3-small: 1536
// - text-embedding-3-large: 3072
// - mxbai-embed-large (Ollama): 1024
CREATE VECTOR INDEX entity_embedding IF NOT EXISTS FOR (n:Entity) ON n.nameEmbedding
OPTIONS {indexConfig: {`vector.dimensions`: 1536, `vector.similarity_function`: 'cosine', `vector.hnsw.ef_construction`: 400, `vector.hnsw.m`: 32}};
CREATE VECTOR INDEX statement_embedding IF NOT EXISTS FOR (n:Statement) ON n.factEmbedding
OPTIONS {indexConfig: {`vector.dimensions`: 1536, `vector.similarity_function`: 'cosine', `vector.hnsw.ef_construction`: 400, `vector.hnsw.m`: 32}};
CREATE VECTOR INDEX episode_embedding IF NOT EXISTS FOR (n:Episode) ON n.contentEmbedding
OPTIONS {indexConfig: {`vector.dimensions`: 1536, `vector.similarity_function`: 'cosine', `vector.hnsw.ef_construction`: 400, `vector.hnsw.m`: 32}};
// Verify indexes were created
SHOW INDEXES YIELD name, type WHERE type = 'VECTOR' RETURN name, type;