cypher - neo4j all relations to certain depth between 2 sets -


playing simple neo4j queries. base match :

match (:movie { id: '10' })-[*0..3]-(p:producer) return p.id 

this returns results, there relations between movie-10 , producer. part of result set is:

'producer_12' 'producer_18' 'producer_36' ......... 

now want return relations between movie-10 , producer_12 or producer_18 3 hops. modified match.

match (:movie { id: '10' })-[*0..3]-(p:producer) p.id in ['producer_12', 'producer_18'] return p.id 

and doesn't return value, while expected producers 12 , 18 in answer. besides can't find way label relation. not accepted. [r:*0..3].

my final query must relations between 2 sets (movies 10, 12 or 15) , (producers 12 or 18) example.

i simulated scenario here.

the sample data:

create (movie:movie {id : '10'}) create (producer12:producer {id:'producer_12'}) create (producer18:producer {id:'producer_18'}) create (producer36:producer {id:'producer_36'}) create (movie)-[:producted_by]->(producer12) create (movie)-[:producted_by]->(producer18) create (movie)-[:producted_by]->(producer36) 

querying:

match (:movie { id: '10' })-[*0..3]-(p:producer) p.id in ['producer_12', 'producer_18'] return p.id 

the result:

╒═════════════╕ │"p.id"       │ ╞═════════════╡ │"producer_12"│ ├─────────────┤ │"producer_18"│ └─────────────┘ 

probably id property of :movie nodes not string integer. try changing query to:

match (:movie { id: 10 })-[*0..3]-(p:producer) p.id in ['producer_12', 'producer_18'] return p.id 

that is: change '10' 10.

besides can't find way label relation. not accepted. [r:*0..3].

this because not using type in relationship. : used in conjunction type (for example, [r:some_type*0..3]). remove :, way: [r *0..3].

edit:

from comments:

about last sentence: it's still working says "this feature deprecated , removed in future versions. binding relationships list in variable length pattern deprecated" – user732456 3 hours ago

binding relationships list in variable length pattern deprecated since 3.2.0-rc1.

according pull request cypher queries like:

match (n)-[rs*]-() return rs 

will generate warning , canonical way write same query is:

match p=(n)-[*]-() return relationships(p) rs 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -