Skip to content

Commit 1419af1

Browse files
authored
Switch to Neo4j enterprise version, and switch to KEY for Neo4j key constraint. (#331)
1 parent 15ef7f8 commit 1419af1

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

dev/neo4j.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: cocoindex-neo4j
22
services:
33
neo4j:
4-
image: neo4j:latest
4+
image: neo4j:5-enterprise
55
volumes:
66
- /$HOME/neo4j/logs:/logs
77
- /$HOME/neo4j/config:/config
@@ -10,6 +10,15 @@ services:
1010
environment:
1111
- NEO4J_AUTH=neo4j/cocoindex
1212
- NEO4J_PLUGINS='["graph-data-science"]'
13+
- NEO4J_ACCEPT_LICENSE_AGREEMENT=eval
14+
15+
# Uncomment to enable query logging
16+
# - NEO4J_db_logs_query_enabled=VERBOSE
17+
# - NEO4J_db_logs_query_transaction_enabled=VERBOSE
18+
# - NEO4J_db_logs_query_parameter__logging__enabled=true
19+
# - NEO4J_dbms_logs_http_enabled=true
20+
# - NEO4J_server_logs_debug_enabled=true
21+
1322
ports:
1423
- "7474:7474"
1524
- "7687:7687"

src/ops/storages/neo4j.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,14 @@ impl RelationshipSetupState {
696696
)
697697
})?;
698698
for (label, node) in rel_spec.nodes.iter().flatten() {
699-
sub_components.push(ComponentState {
700-
object_label: ElementType::Node(label.clone()),
701-
index_def: IndexDef::KeyConstraint {
702-
field_names: key_field_names.clone(),
703-
},
704-
});
699+
if let Some(primary_key_fields) = &node.index_options.primary_key_fields {
700+
sub_components.push(ComponentState {
701+
object_label: ElementType::Node(label.clone()),
702+
index_def: IndexDef::KeyConstraint {
703+
field_names: primary_key_fields.clone(),
704+
},
705+
});
706+
}
705707
for index_def in &node.index_options.vector_indexes {
706708
sub_components.push(ComponentState {
707709
object_label: ElementType::Node(label.clone()),
@@ -885,8 +887,12 @@ impl components::Operator for SetupComponentOperator {
885887
let matcher = state.object_label.matcher(qualifier);
886888
let query = neo4rs::query(&match &state.index_def {
887889
IndexDef::KeyConstraint { field_names } => {
890+
let key_type = match &state.object_label {
891+
ElementType::Node(_) => "NODE",
892+
ElementType::Relationship(_) => "RELATIONSHIP",
893+
};
888894
format!(
889-
"CREATE CONSTRAINT {name} IF NOT EXISTS FOR {matcher} REQUIRE {field_names} IS UNIQUE",
895+
"CREATE CONSTRAINT {name} IF NOT EXISTS FOR {matcher} REQUIRE {field_names} IS {key_type} KEY",
890896
name=key.name,
891897
field_names=build_composite_field_names(qualifier, &field_names),
892898
)

0 commit comments

Comments
 (0)