age-website
age-website copied to clipboard
QUESTION: Node Constraints on Property
Is there a way to create constraints for node/vertex properties? I want to use concurrent loading of AGE but need constraints to avoid multiple threads from creating duplicate nodes/vertex. I tried this:
ON pubmed."Article"
((properties->>'pmid'));
but I get this error:
operator does not exist: ag_catalog.agtype ->> unknown
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Are constraints on a Node property possible?
I tried this and so far it seems to work:
CREATE UNIQUE INDEX article_aid_idx ON news."Article"(ag_catalog.agtype_access_operator(properties, '"aid"'::ag_catalog.agtype));
Is there a better way?
Hi @stugorf Thank you very much for sharing this issue. Our team is already looking into it. In the meantime, please do not hesitate to reach out if you have any questions.
@stugorf, you got it right, you have to explicitly cast to agtype arguments of functions that receive this kind of type.
To make it a little more concise, you can set the search_path to ag_catalog after loading AGE on each session:
LOAD 'age';
SET search_path TO ag_catalog;
This will allow you to keep the ag_catalog
term out of your queries, making it a bit shorter:
CREATE UNIQUE INDEX article_aid_idx ON news."Article"(agtype_access_operator(properties, '"aid"'::agtype));
Please let us know if your current solution is working fine for you.
@jimenasansav @markgomer The solution, with the addition of setting the search path, is working well so far. My name is David, I lead the graph practice for a large consultancy, Graphable, and I am very interested in AGE. I would like to explore ways to contribute more to AGE and consider it for our client solutions.