find the particular node which fit three criteria neo4j





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















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.
enter image description here
However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
enter image description here



I don't know which part of the cypher is incorrect. thank you for helping










share|improve this question





























    0















    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.
    enter image description here
    However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
    enter image description here



    I don't know which part of the cypher is incorrect. thank you for helping










    share|improve this question

























      0












      0








      0








      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.
      enter image description here
      However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
      enter image description here



      I don't know which part of the cypher is incorrect. thank you for helping










      share|improve this question














      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.
      enter image description here
      However, I just want the following. Just the one who trade Grapes, Orange and Apple only.
      enter image description here



      I don't know which part of the cypher is incorrect. thank you for helping







      neo4j






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 4:16









      Platalea MinorPlatalea Minor

      16412




      16412
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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





          share|improve this answer
























          • 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 '18 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 '18 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 '18 at 9:40











          • Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

            – InverseFalcon
            Dec 5 '18 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 '18 at 5:11












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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





          share|improve this answer
























          • 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 '18 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 '18 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 '18 at 9:40











          • Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

            – InverseFalcon
            Dec 5 '18 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 '18 at 5:11
















          0














          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





          share|improve this answer
























          • 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 '18 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 '18 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 '18 at 9:40











          • Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

            – InverseFalcon
            Dec 5 '18 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 '18 at 5:11














          0












          0








          0







          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





          share|improve this answer













          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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 4:38









          InverseFalconInverseFalcon

          19.9k31831




          19.9k31831













          • 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 '18 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 '18 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 '18 at 9:40











          • Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

            – InverseFalcon
            Dec 5 '18 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 '18 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 '18 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 '18 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 '18 at 9:40











          • Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

            – InverseFalcon
            Dec 5 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 9:40













          Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

          – InverseFalcon
          Dec 5 '18 at 19:45





          Then just change up the last WHERE clause with the numbers you want: WHERE cnt >= 3

          – InverseFalcon
          Dec 5 '18 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 '18 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 '18 at 5:11




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?