我試圖過濾包含用戶實體的提要。我正在使用@QueryResult對象來檢索結果。我需要訂閱源和用戶喜歡的訂閱源的關係信息。但是,當檢索提供的錯誤時:org.neo4j.rest.graphdb.entity.RestNode不能轉換爲java.lang.Iterable。 (我使用SDN 3.3.0.RELEASE和Neo4j的2.1.7)獲取錯誤org.neo4j.rest.graphdb.entity.RestNode無法轉換爲java.lang.Iterable
@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);
如果我轉換查詢通過盧安妮的建議,我收到以下錯誤: 類型不匹配:預計地圖,節點或關係,但是集合。
新查詢:
@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);
但我可以發送收集(飼料)和收集(相對)的工會?我也試過,但沒有奏效。 –
我編輯了查詢,你可以再看看。 –
聯盟是否返回一兩行? – Luanne