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;


The result for the above query










share|improve this question
























  • 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















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;


The result for the above query










share|improve this question
























  • 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













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;


The result for the above query










share|improve this question















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;


The result for the above query







neo4j






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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;





share|improve this answer





















    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',
    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%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

























    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;





    share|improve this answer

























      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;





      share|improve this answer























        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;





        share|improve this answer












        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;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        stdob--

        18.7k42948




        18.7k42948






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]