find the particular node which fit three criteria neo4j
up vote
0
down vote
favorite
I would like to find the name node which trade with three fruits only.
I tried to use the following code in neo4j.
match (s:good)-[r:TRADES]-(n:Name)-[:TRADES]-(p:good)
WHERE (s.good = 'Apple' or s.good='Orange') and p.stock ='Grapes'
return s,n,p
where it returns the query as below.
However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
I don't know which part of the cypher is incorrect. thank you for helping
neo4j
add a comment |
up vote
0
down vote
favorite
I would like to find the name node which trade with three fruits only.
I tried to use the following code in neo4j.
match (s:good)-[r:TRADES]-(n:Name)-[:TRADES]-(p:good)
WHERE (s.good = 'Apple' or s.good='Orange') and p.stock ='Grapes'
return s,n,p
where it returns the query as below.
However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
I don't know which part of the cypher is incorrect. thank you for helping
neo4j
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to find the name node which trade with three fruits only.
I tried to use the following code in neo4j.
match (s:good)-[r:TRADES]-(n:Name)-[:TRADES]-(p:good)
WHERE (s.good = 'Apple' or s.good='Orange') and p.stock ='Grapes'
return s,n,p
where it returns the query as below.
However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
I don't know which part of the cypher is incorrect. thank you for helping
neo4j
I would like to find the name node which trade with three fruits only.
I tried to use the following code in neo4j.
match (s:good)-[r:TRADES]-(n:Name)-[:TRADES]-(p:good)
WHERE (s.good = 'Apple' or s.good='Orange') and p.stock ='Grapes'
return s,n,p
where it returns the query as below.
However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
I don't know which part of the cypher is incorrect. thank you for helping
neo4j
neo4j
asked Nov 22 at 4:16
Platalea Minor
13410
13410
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
We have a knowledge base article on match intersection, what you're trying to do here, however your other restriction is that these are the only 3 connected nodes, so we have some additional work to do.
Using the first approach in the article, we just have to add an additional predicate to ensure the degree of :TRADES relationships equals the size of the collection:
WITH ['Apple', 'Orange', 'Grapes'] as names
MATCH (g:good)<-[:TRADES]-(n:Name)
WHERE g.good in names AND size((n)-[:TRADES]->()) = size(names)
WITH n, size(names) as inputCnt, count(DISTINCT g) as cnt
WHERE cnt = inputCnt
RETURN n
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
We have a knowledge base article on match intersection, what you're trying to do here, however your other restriction is that these are the only 3 connected nodes, so we have some additional work to do.
Using the first approach in the article, we just have to add an additional predicate to ensure the degree of :TRADES relationships equals the size of the collection:
WITH ['Apple', 'Orange', 'Grapes'] as names
MATCH (g:good)<-[:TRADES]-(n:Name)
WHERE g.good in names AND size((n)-[:TRADES]->()) = size(names)
WITH n, size(names) as inputCnt, count(DISTINCT g) as cnt
WHERE cnt = inputCnt
RETURN n
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
add a comment |
up vote
0
down vote
accepted
We have a knowledge base article on match intersection, what you're trying to do here, however your other restriction is that these are the only 3 connected nodes, so we have some additional work to do.
Using the first approach in the article, we just have to add an additional predicate to ensure the degree of :TRADES relationships equals the size of the collection:
WITH ['Apple', 'Orange', 'Grapes'] as names
MATCH (g:good)<-[:TRADES]-(n:Name)
WHERE g.good in names AND size((n)-[:TRADES]->()) = size(names)
WITH n, size(names) as inputCnt, count(DISTINCT g) as cnt
WHERE cnt = inputCnt
RETURN n
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
We have a knowledge base article on match intersection, what you're trying to do here, however your other restriction is that these are the only 3 connected nodes, so we have some additional work to do.
Using the first approach in the article, we just have to add an additional predicate to ensure the degree of :TRADES relationships equals the size of the collection:
WITH ['Apple', 'Orange', 'Grapes'] as names
MATCH (g:good)<-[:TRADES]-(n:Name)
WHERE g.good in names AND size((n)-[:TRADES]->()) = size(names)
WITH n, size(names) as inputCnt, count(DISTINCT g) as cnt
WHERE cnt = inputCnt
RETURN n
We have a knowledge base article on match intersection, what you're trying to do here, however your other restriction is that these are the only 3 connected nodes, so we have some additional work to do.
Using the first approach in the article, we just have to add an additional predicate to ensure the degree of :TRADES relationships equals the size of the collection:
WITH ['Apple', 'Orange', 'Grapes'] as names
MATCH (g:good)<-[:TRADES]-(n:Name)
WHERE g.good in names AND size((n)-[:TRADES]->()) = size(names)
WITH n, size(names) as inputCnt, count(DISTINCT g) as cnt
WHERE cnt = inputCnt
RETURN n
answered Nov 22 at 4:38
InverseFalcon
17.8k21828
17.8k21828
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
add a comment |
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
Hi @InverseFalcon I would like to know if I have another query with more than 5 fruits. What I need to need change is from three elements to five elements on WITH ['Apple', 'Orange', 'Grapes'] as names ?
– Platalea Minor
Dec 5 at 8:17
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
The type of query provided doesn't use any hard-coded numbers for expected values, if you read through it you should notice it uses the number of elements in your input, so whether it's 3 or 5 or 5000 it should work the same.
– InverseFalcon
Dec 5 at 9:28
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
However, if I want to query if any name node which have connected with three or more fruit nodes. I think this query won't be able to provide the name nodes?
– Platalea Minor
Dec 5 at 9:40
Then just change up the last WHERE clause with the numbers you want:
WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Then just change up the last WHERE clause with the numbers you want:
WHERE cnt >= 3
– InverseFalcon
Dec 5 at 19:45
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
Hi @InverseFalcon Thank you for your help, yet it cannot resolve the question. I have raised another question below. If you have time please take a look. Thank you so much stackoverflow.com/questions/53629951/find-cluster-in-neo4j
– Platalea Minor
Dec 6 at 5:11
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53423820%2ffind-the-particular-node-which-fit-three-criteria-neo4j%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