I am trying to filter feeds which contains user actvitity. I am using @QueryResult object to retrieve the result. I need both the feeds and the relationship information of user Liked Feeds. But while retrieving the feeds getting error: org.neo4j.rest.graphdb.entity.RestNode cannot be cast to java.lang.Iterable. (I am using SDN 3.3.0.RELEASE and neo4j 2.1.7)
@QueryResult
public interface FeedsIterableResult {
@ResultColumn("f")
Collection<Feed> getFeeds();
@ResultColumn("r")
Collection<UserInspiredByFeed> getPaths();
}
@Query("match (feed:Feed)-[:FEED_CONTAINS_TAG]->(t:Tag)<-[:USER_FAVORITED_TAG]-(u:User{username:{1}}) "
+ "where feed.feedType in {0} "
+ "with u, feed "
+ "optional match (u)-[rel:USER_LIKED_FEED]->(feed) "
+ "return feed as f, rel as r "
+ "union match (u:User{username:{1}})-[:USER_FAVORITED_USER]->(u2:User)-[:USER_LIKED_FEED|:USER_CREATED_FEED]->(feed:Feed) "
+ "where feed.feedType in {0} "
+ "with u2, feed "
+ "optional match (u2)-[rel:USER_LIKED_FEED]->(feed) "
+ "return feed as f, rel as r "
+ "order by f.timeAdded desc "
+ "skip {2} limit {3}")
FeedsIterableResult getAllFavoriteFeeds(String[] typeFilter, String userName, int skip, int limit);
If I convert the query as suggested by Luanne, I am getting following error: Type mismatch: expected Map, Node or Relationship but was Collection.
New Query:
@QueryResult
public interface FeedsIterableResult {
@ResultColumn("f")
List<Feed> getFeeds();
@ResultColumn("r")
List<UserInspiredByFeed> getPaths();
}
@Query("match (feed:Feed)-[:FEED_CONTAINS_TAG]->(t:Tag)<-[:USER_FAVORITED_TAG]-(u:User{username:{1}}) "
+ "where feed.feedType in {0} "
+ "with u, feed "
+ "optional match (u)-[rel:USER_INSPIREDBY_FEED]->(feed) "
+ "return collect(feed) as f, collect(rel) as r "
+ "union match (u:User{username:{1}})-[:USER_FAVORITED_USER]->(u2:User)-[:USER_INSPIREDBY_FEED|:USER_CREATED_FEED]->(feed:Feed) "
+ "where feed.feedType in {0} "
+ "with u2, feed "
+ "optional match (u2)-[rel:USER_INSPIREDBY_FEED]->(feed) "
+ "return collect(feed) as f, collect(rel) as r "
+ "order by f.timeAdded desc "
+ "skip {2} limit {3}")
FeedsIterableResult getAllFavoriteFeeds(String[] typeFilter, String userName, int skip, int limit );