Skip to content

Commit

Permalink
Allow skipping index creation for flows with read-only user
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasonjo committed Dec 9, 2024
1 parent bf8b6cf commit fc6923b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(
refresh_schema: bool = True,
sanitize_query_output: bool = True,
enhanced_schema: bool = False,
create_indexes: bool = True,
**neo4j_kwargs: Any,
) -> None:
self.sanitize_query_output = sanitize_query_output
Expand All @@ -167,22 +168,24 @@ def __init__(
self.structured_schema = {}
if refresh_schema:
self.refresh_schema()
# Create index for faster imports and retrieval
self.structured_query(
f"""CREATE CONSTRAINT IF NOT EXISTS FOR (n:`{BASE_NODE_LABEL}`)
REQUIRE n.id IS UNIQUE;"""
)
self.structured_query(
f"""CREATE CONSTRAINT IF NOT EXISTS FOR (n:`{BASE_ENTITY_LABEL}`)
REQUIRE n.id IS UNIQUE;"""
)
# Verify version to check if we can use vector index
self.verify_version()
if self._supports_vector_index:
# Create index for faster imports and retrieval
if create_indexes:
self.structured_query(
f"CREATE VECTOR INDEX {VECTOR_INDEX_NAME} IF NOT EXISTS "
"FOR (m:__Entity__) ON m.embedding"
f"""CREATE CONSTRAINT IF NOT EXISTS FOR (n:`{BASE_NODE_LABEL}`)
REQUIRE n.id IS UNIQUE;"""
)
self.structured_query(
f"""CREATE CONSTRAINT IF NOT EXISTS FOR (n:`{BASE_ENTITY_LABEL}`)
REQUIRE n.id IS UNIQUE;"""
)

if self._supports_vector_index:
self.structured_query(
f"CREATE VECTOR INDEX {VECTOR_INDEX_NAME} IF NOT EXISTS "
"FOR (m:__Entity__) ON m.embedding"
)

@property
def client(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-graph-stores-neo4j"
readme = "README.md"
version = "0.4.0"
version = "0.4.1"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
Expand Down

0 comments on commit fc6923b

Please sign in to comment.