Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j - Match multiple Nodes using IDs

Tags:

neo4j

cypher

I need to retrieve multiple nodes in Neo4j and I only have there IDs.

Is there a way to retrieve nodes that have their ID in the given set in one cypher query ? Or do I have to call the db for each ID ?

I'm using Neo4j 2.1.5

Thanks !

like image 341
Czoo Avatar asked Oct 20 '14 13:10

Czoo


People also ask

Can u relabel node in Neo4j?

You can change the nodes associated with a label but you can't change the type of a relationship. Conceptually, if you take your chicken out of one coop and put it in another you haven't altered the substance of the chicken.

How do you create a relationship between two nodes in Neo4j?

To create a relationship between two nodes, we first get the two nodes. Once the nodes are loaded, we simply create a relationship between them. The created relationship is returned by the query.

How do I return all nodes and relationships in Neo4j?

Return all elements When you want to return all nodes, relationships and paths found in a query, you can use the * symbol.

Why would you use Neo4j match?

The MATCH clause allows you to specify the patterns Neo4j will search for in the database. This is the primary way of getting data into the current set of bindings. It is worth reading up more on the specification of the patterns themselves in Patterns.


1 Answers

You can match within an Array.

MATCH (u:`User`) WHERE ID(u) IN [1, 2, 3] RETURN u
like image 61
subvertallchris Avatar answered Sep 24 '22 21:09

subvertallchris