apache / apache/age

unique properties / indexing

Open
#45 25 comments 9 reactions 0 assignees View on GitHub
enhancement
Dominant language
C
Stars
4.8k
Forks
523
Avg merge
1d 2h
Merged PRs (30d)
9

Description

Hello, it would be great if we could use unique keys in nodes and edges. in Neo4j it's called [Node Key](https://neo4j.com/docs/cypher-manual/current/administration/constraints/#administration-constraints-node-key) and it can be used like these:

1. `CREATE CONSTRAINT constraint_name ON (n:Person) ASSERT (n.firstname) IS NODE KEY`
2. `CREATE CONSTRAINT constraint_name ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEY`
3. `CREATE CONSTRAINT constraint_name IF NOT EXISTS ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEY`
4. `CREATE CONSTRAINT constraint_with_provider ON (n:Label) ASSERT (n.prop1) IS NODE KEY OPTIONS {indexProvider: 'native-btree-1.0'}`
5. `DROP CONSTRAINT constraint_name`
6. `DROP CONSTRAINT missing_constraint_name IF EXISTS`

I've tried to use Postgres queries but since the `properties` column type is not json/jsonb I got error:
```sql
postgres=# CREATE UNIQUE INDEX person_name_idx ON mygraph.person( (properties->>'name') ) ;
ERROR: operator does not exist: ag_catalog.agtype ->> unknown
LINE 1: ...INDEX person_name_idx ON mygraph.person( (properties->>'name')...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.