Using cypher, is there any way to match a path where the relationships satisfy a certain input schema generically?
I know I can do something like
parameters: {
"age": 20
}
MATCH (n)-[r:MY_RELATION]-() WHERE $age>18 AND $age<24 ...
when i want to match only relations satisfying the schema { "type": "integer", "minimum": 19, "maximum": 23 }
.
But then i have to specify the min and max range within the relationship. What if I want to match strings against a schema, or even more complex types like address with subparameters etc.?
Is there a generic way to do it?
edit: I'll try and state the question more clearly. What I want is a graph and a (parameterized) query to traverse that graph, such that:
- i get all the nodes in the traversal
- the relationships in the graph pose certain constraints on the query parameters (like minimum on an integer)
- the traversal only follows edges where the constraint is met
- i need to make constraints on integers, like min/max, but as well on strings, like pattern, etc.
edit 2: What I want may not even be possible. I want all of the information about the constraint to reside in the edge, including the parameter to test against. So I would want something along the lines of
parameters: { "age": 20, "location": "A" }
MATCH (n)-[r]-()
WHERE r.testtype='integer' AND getParameterByName(r.testparamname) < r.max
OR r.testtype='string' AND getParameterByName(r.testparamname)=r.allowedStringValue
Of course, as can be read in the neo4j documentation about parameter functionality it should not be possible to dynamically load the parameter via a name that resides in the DB.
There may yet be some workaround?