Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-17-2021 01:26 AM
Hello,
I am using spring data neo4j and i have a repository like this :
public interface MyNeo4jRepository extends Neo4jRepository<Object, Long> {
@Query("with ['X', 'Y','Z'] as list_labels, "
+ "$appsFilter as appsList\n "
+ "MATCH (apps:) where apps.n IN appsList "
+ "MATCH (a)<-[:event]-(nodes) "
+ "WHERE any(x IN labels(nodes) WHERE x IN list_labels) "
+ "CALL apoc.path.expandConfig(nodes, { "
+ "relationshipFilter: 'R1|R2>',"
+ "labelFilter: '-l1|>l2',"
+ "maxLevel: 6,"
+ "endNodes: [apps],"
+ "uniqueness: 'NODE_PATH'}) YIELD path "
+ "unwind nodes(path) as n "
...
}
what i want is to create this query using conditions like this :
@Query("with ['X', 'Y','Z'] as list_labels, "
+ "$appsFilter as appsList\n "
+ "MATCH (apps:) where apps.n IN appsList "
+ "MATCH (a)<-[:event]-(nodes) "
+ "WHERE any(x IN labels(nodes) WHERE x IN list_labels) "
if (condition) + "WHERE ...." else + ""
+ "CALL apoc.path.expandConfig(nodes, { "
...
Thnak you
08-19-2021 12:59 PM
Hi @madiskou !
I dont think you can do something like that . You may need to create two different custom queries and handle them on your service layer. Or you can always use apoc.when and let the db itself handle the condition.
Yeah I know it's not what you expected tho
H
08-20-2021 12:45 AM
You have various options when it comes to expression conditions: Conditional Cypher Execution - Knowledge Base : CASE..WHEN, FOREACH trick, APOC...
All the sessions of the conference are now available online