age
age copied to clipboard
Support for PIPE operator for apache-age-python client
Currently we are running queries that require several Relationship (age.models.Edge) types to be filtered out. We tried to approach it with OPTIONAL MATCH but it didn't suite as too well, since it requires first statement to have matches to process with the other. Ended up with something like "MATCH ()-[r]-() WHERE r.type in ["type1", "type2"] RETURN r". In OpenCypher specs there is a mention about PIPE operator that facilitates such OR statements for relationship types and it goes like: "MATCH ()-[r:type1|type2]-() RETURN r. It feels a lot more natural to use. This one gives us "syntax error near |'.
Are there any plans to implement such operator or is it somehow limited?
Yes PIPE is cutoff. It is no more supported for specifying relationship types in single pattern.
But after checking some doc have you tried using WHERE clause with IN I think this might WORK like WHERE r.type IN ['type1', 'type2']
@farakh-shahid That is exactly what @czesiu89 is saying he's using as workaround, indeed.
Is there any reason why PIPE is "no more supported"? Does it imply that Age is not implementing 100% OpenCypher? As I believe it's part of its grammar?
Thanks a lot!
Hi @czesiu89 Any new updates on this? Can you share a bit more about your use-case? It'll help us prioritize.
The PIPE operator is a feature of the Nebula Graph Query Language (nGQL) and is not part of OpenCypher. It allows multiple queries to be combined using pipe operators in nGQL. The PIPE operator applies to native nGQL only and is not compatible with OpenCypher
@cvanlabe -
@farakh-shahid That is exactly what @czesiu89 is saying he's using as workaround, indeed.
Is there any reason why PIPE is "no more supported"? Does it imply that Age is not implementing 100% OpenCypher? As I believe it's part of its grammar?
Thanks a lot!
Can you please show me where in the openCypher documentation it states the pipe operator was/is supported?
@jrgemignani thanks for your response. As I mentioned, it’s visible in the grammar I linked to.
In the documentation, it’s described as early as page 10 in the opencypher reference:
” if we’d like to describe some data such that the relationship could have any one of a set of types, then they can all be listed in the pattern, separating them with the pipe symbol | like this:”
(a)-[r:TYPE1|TYPE2]->(b)
I will bring this "oversight" up with the team and see if we can get it added. @rafsun42 @dehowef @muhammadshoaib
Btw, the title for this issue is a bit misleading. This issue is for adding the OR operator | to the language for the edge match.
@czesiu89 @cvanlabe The work on this operator is currently in progress. It would be useful if you let us know your data model and queries.
Thanks so much everyone! We can't immediately share our data model we use today. Assume it's a typical graph, which has several nodes connected to other nodes where each connection is a different relation type. Using the OR operator, we can decide which nodes we want to visualize given the used relationships.
I hope this helps.
hi, i face a situation where the pipe-OR operator would be usefull, so as my situation is pretty simple i describe it here.
this is the query i tried, in which i want to match synonyms or hyperonyms of a word, and synonym/hyperonyms of synonym/hyperonyms, and synonym/hyperonyms of synonym/hyperonym of synonym/hyperonym of this word (including pattern like: synonym -> hyperonym -> synonym, and so on). so i need variable-length edges and the OR operator.
select * from cypher('graph_dict', $$
match (s:word {graphic_form: 'know'})-[r:has_synonym|has_hyperonym|has_holonym *1..3]->(t:word)
return s, t
$$) as (source agtype, target agtype);
with the solution proposed in the beginning of this discussion, it produces an error. this is what i've tried:
select * from cypher('graph_dict', $$
match (s:word {graphic_form: 'know'})-[r]->(m:word)-[s *0..2]->(t:word)
where label(r) in ['has_synonym', 'has_hyperonym', 'has_holonym']
and label(s) in ['has_synonym', 'has_hyperonym', 'has_holonym']
return l.id, t.graphie
$$) as (source agtype, target agtype);
the error is the following, and it seems that when the second edge is length 0, label() cannot be used (obviously).
ERROR: label() argument must resolve to a vertex or an edge.
my data structure is very simple: vertices are words (with a graphic_form and an id) and edges are relations between these words (has_synonym, has_antonym, has_hyperonym, ...).
@thjbdvlt PR #1452 implements multiple label support. It has not been approved yet, but you can try it out.
@rafsun42 thank you! i am currently on PG15 so i cannot compile with it (PR 1452), but i'll try to upgrapde to PG16 soon so i can try it out, because it seems to be what i need! :)
@thjbdvlt The PR 1452 is actually based on PG15. Do you get a compilation error?
@rafsun42 unfortunately: yes! but as i am really not a programmer, i have no doubts: it must be because of me not understanding something. anyway, i post a comment directly on the PR 1452 page with logs and description of what i have done, just in case it may help!
This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.
This issue is stale because it has been open 60 days with no activity. Remove "Abondoned" label or comment or this will be closed in 14 days.