Reputation: 250
I have two nodes user and account and the relationship between them is any one of the 25 relationship. My Query is
MATCH (u:User)-[r:rel1|rel2|rel3|rel4]->(a:Account) WHERE u.login_id=~('(?i).*'+{fulltextsearch}+'.*') RETURN u as User,r as acronym
My user pojo is
public class User{
@GraphId
private Long id;
String fulltextsearch;
String user_id;
String status;
//@Relationship(type = "rel1", direction= Relationship.OUTGOING)
Acronym acronym;
public Acronym getAcronym() {
return acronym;
}
private Set<Account> accounts;
public User() {
}
public String getUser_id() {
return user_id;
}
public String getStatus() {
return status;
}
public String getFulltextsearch() {
return fulltextsearch;
}
public Set<Account> getAccounts() {
return accounts;
}
public void setAccounts(Set<Account> accounts) {
this.accounts = accounts;
}
}
I am confused in writing my user pojo with multiple relatioships. can I give @Relatioship for multiple relatioship with OR.
like this @Relationship(type = "rel1 | rel2", direction= Relationship.OUTGOING)
Upvotes: 0
Views: 96
Reputation: 19373
No, you cannot supply multiple relationship types to the @Relationship
. You will have to declare them independently in your entity:
@Relationship(type = "rel1", direction= Relationship.OUTGOING)
Acronym acronymRel1;
@Relationship(type = "rel2", direction= Relationship.OUTGOING)
Acronym acronymRel2;
You can write a custom query to fetch all Acronyms based on a set of relationship types.
Upvotes: 1