I have created the following query which works fine when i am passing all the relationship.
@Query(value="START profile=node(*) "
+ "MATCH profile - [rel:create | stream | like | follow] - feeds "
+ "WHERE profile.id ={profileId} "
+ "WITH distinct feeds as feed, rel.date as date "
+ "ORDER BY date DESC "
+ "RETURN DISTINCT feed;")
public List<Feed> findByProfileId(@Param("profileId") String profileId);
but i want to fetch data for specific action like the query below
@Query(value="START profile=node(*) "
+ "MATCH profile - [rel:{action}] - feeds "
+ "WHERE profile.id ={profileId} "
+ "WITH distinct feeds as feed, rel.date as date "
+ "ORDER BY date DESC "
+ "RETURN DISTINCT feed;")
public List<Feed> findByProfileId(@Param("action") String action,@Param("profileId") String profileId);
But this does not work and i get the following error.
org.neo4j.rest.graphdb.RestResult Exception: Invalid input '{': expected whitespace or an identifier
I think this is not a correct way to pass param in relationship. Is there a way how i can achieve this.
you should not use start n=node(*)
in your query use a label like :Profile
and an index/unique constraint on :Profile(id)
MATCH (profile:Profile) WHERE profile.id = {profileId}
you can't use rel-types as parameters directly but you can check the type of your relationship, eg against a set of names that is passed in
either
WHERE type(rel) = {action}
or
WHERE type(rel) IN {actions}
There is no way currently to pass relationship types nor labels as query parameters.
You will need to handle it in your application, when building the query string.
Here is a simple example in PHP :
$relTypes = array(':FACEBOOK_PROFILE',':TWITTER_PROFILE');
$relString = implode('|', $relTypes);
$q = 'MATCH (n:User)-['.$relString.']->(profile)';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.