1
votes

how can I find pattern relationships using rest cypher?

My query running on terminal :-

MATCH (n)<-[:DEPENDS_ON*]-(dependent) RETURN n.host as Host,

count(DISTINCT dependent) AS Dependents ORDER BY Dependents DESC LIMIT 1**

output is :-

+--------------------+ | Host | Dependents |

+--------------------+ | "SAN" | 20 | +--------------------+

where as equivalent query with rest :-

String query = "{\"query\" : \"MATCH (website)<-[rel]-(dependent) " +
                "WHERE TYPE(rel) = {rtype} RETURN website.host as Host," +
                "count(DISTINCT dependent) AS Dependents ORDER BY Dependents DESC LIMIT 1" +
                " \", \"params\" : {\"rtype\" : \"DEPENDS_ON*\"}}";     

and output is empty(no records) !!!

Any help appreciated.

P.S- When we dont use "*" in our query everything goes ok. IE both queries give same result

1

1 Answers

1
votes

In the second query you are passing the relationship type as "DEPENDS_ON*" which is incorrect since the asterisk is being included.

The asterisk is for allowing arbitrary length paths for the specified relationship but is not part of the type.