Reputation: 21
How can I create a query which searches based on the IN clause? The documentation seems unclear? The following code compiles and runs, but the result set is not the expected nodes.
public interface SomeRepository extends GraphRepository<SomeNode> {
@Query("START n=node({nodeid}) MATCH (n)-[r]-(p) WHERE p.id IN [{someids}] RETURN p")
public Set<SomeNode> findByIds(@Param("nodeid") Long rootNodeId, @Param("someids") Set<Long> someIds);
}
@NodeEntity
public class SomeNode {
@GraphId
private Long internalId;
@Indexed(unique = true)
private Long id;
// getters setters omitted.
}
Thank you.
Upvotes: 0
Views: 1036
Reputation: 1352
As you have mentioned in your comment , you should remove the "[]" from your IN clause. A sample working Query in Spring-Data
@Query("MATCH (item:Item{id:{0}})-[:ALIGNS_TO]->(category:Category)
,(suggestItem:Item)-[:ALIGNS_TO]->(category)
Where NOT(suggestItem.id IN {2})
return suggestItem.id
ORDER BY suggestItem.avg_rating DESC limit {1} ")
List<Integer> getCategoryItems( Integer itemId,int limit ,Set<Integer> excludeSet);
Upvotes: 2