-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_indexes.py
More file actions
67 lines (56 loc) · 2.08 KB
/
create_indexes.py
File metadata and controls
67 lines (56 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""
Script to manually create vector indexes for Neo4j EPS document database
"""
from neo4j import GraphDatabase
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
def create_vector_indexes():
"""Create vector indexes for EPS documents using mxbai-embed-large (1024 dimensions)"""
uri = os.getenv("NEO4J_URI", "bolt://localhost:7687")
user = os.getenv("NEO4J_USER", "neo4j")
password = os.getenv("NEO4J_PASSWORD", "research2025")
driver = GraphDatabase.driver(uri, auth=(user, password))
try:
with driver.session() as session:
# Create EPS document content embeddings index (1024 dimensions for mxbai-embed-large)
print("Creating EPS document content embeddings vector index...")
session.run("""
CREATE VECTOR INDEX eps_document_embeddings IF NOT EXISTS
FOR (d:EPSDocument)
ON d.content_embedding
OPTIONS {
indexConfig: {
`vector.dimensions`: 1024,
`vector.similarity_function`: 'cosine'
}
}
""")
# Create topic embeddings index
print("Creating topic embeddings vector index...")
session.run("""
CREATE VECTOR INDEX topic_embeddings IF NOT EXISTS
FOR (t:Topic)
ON t.embedding
OPTIONS {
indexConfig: {
`vector.dimensions`: 1024,
`vector.similarity_function`: 'cosine'
}
}
""")
print("✓ All vector indexes created successfully!")
except Exception as e:
print(f"Error creating vector indexes: {e}")
return False
finally:
driver.close()
return True
if __name__ == "__main__":
success = create_vector_indexes()
if success:
print("\n✅ Vector indexes creation completed!")
else:
print("\n❌ Vector indexes creation failed!")