How to filter the nodes in Neo4j using the relationship property that is of type List
up vote
1
down vote
favorite
How to retrieve all the influencers for a specific user and based on specific property in a relationship defined for example in the below example I want retrieve all the influencers for p1 in prid= 'c1' and projects IN only PR1?
Sample Data Set
CREATE (p1:People {name:'P1 User', id: 'p001'})
CREATE (p2:People {name:'P2 User', id: 'p002'})
CREATE (p3:People {name:'P3 User', id: 'p003'})
CREATE (p4:People {name:'P4 User', id: 'p004'})
CREATE (p5:People {name:'P5 User', id: 'p005'})
CREATE
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR2']}]-(p2),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR4']}]-(p3),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p4),
(p2)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p3),
(p3)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p4),
(p4)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p5)
MATCH (p:People{gsid:'p001'})<-[r:INFLUNCED_BY]-(:People)
WHERE r.prid='c1' AND r.projects IN ['PR1']
RETURN p,r;
The above query is returning no records even though the following relationships exists
MATCH (node) RETURN node;
neo4j
add a comment |
up vote
1
down vote
favorite
How to retrieve all the influencers for a specific user and based on specific property in a relationship defined for example in the below example I want retrieve all the influencers for p1 in prid= 'c1' and projects IN only PR1?
Sample Data Set
CREATE (p1:People {name:'P1 User', id: 'p001'})
CREATE (p2:People {name:'P2 User', id: 'p002'})
CREATE (p3:People {name:'P3 User', id: 'p003'})
CREATE (p4:People {name:'P4 User', id: 'p004'})
CREATE (p5:People {name:'P5 User', id: 'p005'})
CREATE
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR2']}]-(p2),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR4']}]-(p3),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p4),
(p2)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p3),
(p3)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p4),
(p4)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p5)
MATCH (p:People{gsid:'p001'})<-[r:INFLUNCED_BY]-(:People)
WHERE r.prid='c1' AND r.projects IN ['PR1']
RETURN p,r;
The above query is returning no records even though the following relationships exists
MATCH (node) RETURN node;
neo4j
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How to retrieve all the influencers for a specific user and based on specific property in a relationship defined for example in the below example I want retrieve all the influencers for p1 in prid= 'c1' and projects IN only PR1?
Sample Data Set
CREATE (p1:People {name:'P1 User', id: 'p001'})
CREATE (p2:People {name:'P2 User', id: 'p002'})
CREATE (p3:People {name:'P3 User', id: 'p003'})
CREATE (p4:People {name:'P4 User', id: 'p004'})
CREATE (p5:People {name:'P5 User', id: 'p005'})
CREATE
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR2']}]-(p2),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR4']}]-(p3),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p4),
(p2)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p3),
(p3)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p4),
(p4)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p5)
MATCH (p:People{gsid:'p001'})<-[r:INFLUNCED_BY]-(:People)
WHERE r.prid='c1' AND r.projects IN ['PR1']
RETURN p,r;
The above query is returning no records even though the following relationships exists
MATCH (node) RETURN node;
neo4j
How to retrieve all the influencers for a specific user and based on specific property in a relationship defined for example in the below example I want retrieve all the influencers for p1 in prid= 'c1' and projects IN only PR1?
Sample Data Set
CREATE (p1:People {name:'P1 User', id: 'p001'})
CREATE (p2:People {name:'P2 User', id: 'p002'})
CREATE (p3:People {name:'P3 User', id: 'p003'})
CREATE (p4:People {name:'P4 User', id: 'p004'})
CREATE (p5:People {name:'P5 User', id: 'p005'})
CREATE
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR2']}]-(p2),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1','PR4']}]-(p3),
(p1)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p4),
(p2)<-[:INFLUENCER {prid:'c1', projects:['PR1']}]-(p3),
(p3)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p4),
(p4)<-[:INFLUENCER {prid:'c1', projects:['PR4','PR5']}]-(p5)
MATCH (p:People{gsid:'p001'})<-[r:INFLUNCED_BY]-(:People)
WHERE r.prid='c1' AND r.projects IN ['PR1']
RETURN p,r;
The above query is returning no records even though the following relationships exists
MATCH (node) RETURN node;
neo4j
neo4j
edited yesterday
asked yesterday
Naveen Kumar D C
266
266
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday
add a comment |
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
First, you do not have the same names for the properties of nodes and type of relationships in the query:
gsid vs id
INFLUNCED_BY vs INFLUENCER
Second, you need to check the intersection of the lists, not the occurrence. So according to the test data:
MATCH (p:People {id:'p001'})<-[r:INFLUENCER]-(:People)
WHERE r.prid ='c1' AND
// Check the lists for intersection
any(p IN r.projects WHERE p IN ['PR1'])
RETURN p, r;
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
First, you do not have the same names for the properties of nodes and type of relationships in the query:
gsid vs id
INFLUNCED_BY vs INFLUENCER
Second, you need to check the intersection of the lists, not the occurrence. So according to the test data:
MATCH (p:People {id:'p001'})<-[r:INFLUENCER]-(:People)
WHERE r.prid ='c1' AND
// Check the lists for intersection
any(p IN r.projects WHERE p IN ['PR1'])
RETURN p, r;
add a comment |
up vote
1
down vote
First, you do not have the same names for the properties of nodes and type of relationships in the query:
gsid vs id
INFLUNCED_BY vs INFLUENCER
Second, you need to check the intersection of the lists, not the occurrence. So according to the test data:
MATCH (p:People {id:'p001'})<-[r:INFLUENCER]-(:People)
WHERE r.prid ='c1' AND
// Check the lists for intersection
any(p IN r.projects WHERE p IN ['PR1'])
RETURN p, r;
add a comment |
up vote
1
down vote
up vote
1
down vote
First, you do not have the same names for the properties of nodes and type of relationships in the query:
gsid vs id
INFLUNCED_BY vs INFLUENCER
Second, you need to check the intersection of the lists, not the occurrence. So according to the test data:
MATCH (p:People {id:'p001'})<-[r:INFLUENCER]-(:People)
WHERE r.prid ='c1' AND
// Check the lists for intersection
any(p IN r.projects WHERE p IN ['PR1'])
RETURN p, r;
First, you do not have the same names for the properties of nodes and type of relationships in the query:
gsid vs id
INFLUNCED_BY vs INFLUENCER
Second, you need to check the intersection of the lists, not the occurrence. So according to the test data:
MATCH (p:People {id:'p001'})<-[r:INFLUENCER]-(:People)
WHERE r.prid ='c1' AND
// Check the lists for intersection
any(p IN r.projects WHERE p IN ['PR1'])
RETURN p, r;
answered yesterday
stdob--
18.7k42948
18.7k42948
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372606%2fhow-to-filter-the-nodes-in-neo4j-using-the-relationship-property-that-is-of-type%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How to create a Minimal, Complete, and Verifiable example: stackoverflow.com/help/mcve
– stdob--
yesterday
Please refer to the edit post
– Naveen Kumar D C
yesterday