Questions tagged [cypher]

Cypher is a graph query language for Neo4j and AgensGraph. For ciphers as in encryption, see cipher.

Cypher is a declarative graph query language provided by the graph database.

If you are doing encryption, use the tag (note spelling) or .

9748 questions
38
votes
3 answers

Find Neo4j nodes where the property is not set

Using Cypher, how can I find a node where a property doesn't exist? For example, I have two nodes: A = {foo: true, name: 'A'}, B = { name: 'B'} Now I'd like to find B, selecting it on the basis of not having the foo property set. How can I do…
Andrei R
  • 4,904
  • 5
  • 25
  • 26
37
votes
1 answer

Neo4j - Match by multiple relationship types

I want to match between entities by multiple relationship types. Is it possible to say the following query: match (Yoav:Person{name:"Yoav"})-[:liked & watched & ... ]->(movie:Movie) return movie I need "and" between all the relation types; Yova…
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
37
votes
2 answers

Neo4j Bidirectional Relationship

Is there a way to create bidirectional relationship in Neo4j using Cypher? I would like the relationship to be bidirectional rather than making two unidirectional relationships in both directions For eg: (A)<-[FRIEND]->(B) Rather…
sgp
  • 1,738
  • 6
  • 17
  • 31
36
votes
1 answer

Check whether a node exists, if not create

I am trying to make a database where every time a node doesn't exist it will create a new one and set a relationship between this node and another. If the node exists, both nodes get a relationship. My problem is that, if I try to connect 2 existing…
Kapotth
  • 393
  • 1
  • 3
  • 8
34
votes
6 answers

get all relationships for a node with cypher

I would like to find out all the incoming and outgoing relationships for a node. I tried couple of queries suggested in other questions but not having much luck. These are the two I tried MATCH (a:User {username: "user6"})-[r*]-(b) RETURN a, r, b I…
jas
  • 1,539
  • 5
  • 17
  • 30
34
votes
2 answers

Why does neo4j warn: "This query builds a cartesian product between disconnected patterns"?

I'm defining the relationship between two entities, Gene and Chromosome, in what I think is the simple and normal way, after importing the data from CSV: MATCH (g:Gene),(c:Chromosome) WHERE g.chromosomeID = c.chromosomeID CREATE…
Sam Hokin
  • 660
  • 1
  • 6
  • 15
33
votes
6 answers

neo4j cypher: how to change the type of a relationship

I can't find a way to change a relationship type in Cypher. Is this operation possible at all? If not: what's the best way achieve this result?
Sovos
  • 3,330
  • 7
  • 25
  • 36
33
votes
3 answers

How to create unique constraint involving multiple properties in Neo4J

I know I can create a unique constraint on a single property with Cypher like CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE. But I was wondering whether it is possible to create a unique constraint which involves multiple properties. If…
victorx
  • 3,267
  • 2
  • 25
  • 35
33
votes
3 answers

How to push values to property array in Cypher?

I have two nodes user and files with a relationship :contains, the relationship has a property idwhich is an array, represented as (:user)-[:contains{id:[12345]}]->(:files) However I want to populate the property array id with values 1111 and 14567…
SarathSprakash
  • 4,614
  • 2
  • 19
  • 35
32
votes
5 answers

neo4j: What is the syntax to set cypher query parameters in the browser interface?

I am trying to run queries from the neo4j browser to reproduce results from my neo4j-javascript-driver client. What is the syntax for defining query parameters in the neo4j b I recently attended a neo4j training session in NYC where the trainer…
Joel Stevick
  • 1,638
  • 2
  • 16
  • 22
32
votes
2 answers

Excluding label names in simple Neo4j Query

Usually I can find everything I need already on SO but not this time. I'm looking for a very simple way to exclude labels, for example (pseudo code): match (n) where n not in (Label1, Label2) return n Sorry about crappy query. In short I have…
Ed Baker
  • 643
  • 1
  • 6
  • 16
32
votes
4 answers

Change node label in neo4j

I have created a node with a wrong label. Is there any way to change node label or relationship type without re-creating it? I have tried something like MATCH n WHERE Id(n)=14 SET n.Labels = 'Person' but it is fault...
tsdaemon
  • 1,439
  • 2
  • 12
  • 14
32
votes
7 answers

How can I return all properties for a node using Cypher?

I understand it is possible to use the wildcard (*) symbol to return all references in a Cypher query, such as: MATCH p:Product WHERE p.price='1950' RETURN *; ==> +----------------------------------------------------------------+ ==> | p …
DavidJ
  • 4,369
  • 4
  • 26
  • 42
31
votes
1 answer

how to add a property to existing node neo4j cypher?

i have created a new node labeled User CREATE (n:User) i want to add a name property to my User node i tried it by MATCH (n { label: 'User' }) SET n.surname = 'Taylor' RETURN n but seems it is not affecting . how can i add properties to a…
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193
31
votes
1 answer

Difference between merge and create unique in Neo4j

I'm trying to figure out what is the difference between MERGE and CREATE UNIQUE. I know these features: MERGE I'm able to create node, if doesn't exist pattern. MERGE (n { name:"X" }) RETURN n; This create node "n" with property name, empty…
EdWood
  • 875
  • 3
  • 19
  • 37