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
124
votes
9 answers

Neo4j - Cypher vs Gremlin query language

I'm starting to develop with Neo4j using the REST API. I saw that there are two options for performing complex queries - Cypher (Neo4j's query language) and Gremlin (the general purpose graph query/traversal language). Here's what I want to know -…
Rubinsh
  • 4,883
  • 10
  • 34
  • 41
112
votes
10 answers

How to reset / clear / delete neo4j database?

We can delete all nodes and relationships by following query. MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r But newly created node get internal id as ({last node internal id} + 1) . It doesn't reset to zero. How can we reset neo4j database such as…
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
108
votes
7 answers

Return node if relationship is not present

I'm trying to create a query using cypher that will "Find" missing ingredients that a chef might have, My graph is set up like so: (ingredient_value)-[:is_part_of]->(ingredient) (ingredient) would have a key/value of name="dye colors". …
Nicholas
  • 7,403
  • 10
  • 48
  • 76
77
votes
8 answers

neo4j how to return all node labels with Cypher?

I can't find how to return a node labels with Cypher. Anybody knows the syntax for this operation?
Sovos
  • 3,330
  • 7
  • 25
  • 36
65
votes
4 answers

LIKE clause in CYPHER Query

It appears that LIKE is not supported in Cypher queries. Is there any other construct that would perform the same task? For instance: start n = node(*) where n.Name LIKE('%SUBSTRING%') return n.Name, n;
johnc
  • 39,385
  • 37
  • 101
  • 139
64
votes
8 answers

Neo4j: Match multiple labels (2 or more)

I would like to do a search, and I would like to start traversing from 2 labels (OR condition). For example, I need to find out all the nodes which have labels either 'Male' or 'Female' and whose property, name =~ '.ail.'.
gaurav.singharoy
  • 3,751
  • 4
  • 22
  • 25
56
votes
1 answer

Add label to existing node with Cypher

How can I add a label to an existing node using a Cypher query?
cheesetaco
  • 721
  • 1
  • 6
  • 11
53
votes
6 answers

What is the difference between multiple MATCH clauses and a comma in a Cypher query?

In a Cypher query language for Neo4j, what is the difference between one MATCH clause immediately following another like this: MATCH (d:Document{document_ID:2}) MATCH (d)--(s:Sentence) RETURN d,s Versus the comma-separated patterns in the same…
Gene M
  • 1,136
  • 1
  • 10
  • 16
51
votes
4 answers

Neo4j: Get all nodes in a graph, even those that are unconnected by relationships

Using Cypher how can I get all nodes in a graph? I am running some testing against the graph and I have some nodes without relationships so am having trouble crafting a query. The reason I want to get them all is that I want to delete all the nodes…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
50
votes
2 answers

Adding relationship to existing nodes with Cypher

I'm trying out Neo4j for the first time. I'm using the 2.0-RC1 community edition. I've created some nodes: MERGE (u:User{username:'admin',password:'admin'}) MERGE (r1:Role{name:'ROLE_ADMIN'}) MERGE (r2:Role{name:'ROLE_WEB_USER'}) MERGE…
Paul Grenyer
  • 1,713
  • 3
  • 30
  • 51
49
votes
6 answers

Neo4j - Is there a cypher query syntax to list (show) all indexes in DB?

I'm looking for something similar to the MySQL ( SHOW INDEXES ). I was able to get a list of indexes using py2neo in Python graphDB = neo4j.GraphDatabaseService() indexes = graphDB.get_indexes(neo4j.Node) print(format(indexes)) but I wanted to…
Bryan Mayes
  • 603
  • 1
  • 6
  • 8
47
votes
7 answers

Show all Nodes and Relationships in Data Browser Tab

How can I show all nodes and relationships in Data Browser tab? What are sample index queries that I can type in in search field?
gruber
  • 28,739
  • 35
  • 124
  • 216
46
votes
2 answers

Why is Neo4J telling me there is no spoon?

I am using Neo4J to represent texts; in the simplest case a text is a sequence of words joined by the relationship LEMMA_TEXT. I am trying to find the Nth word after a known word, with a query that looks something like this. MATCH…
tla
  • 553
  • 3
  • 7
45
votes
4 answers

Running a case-insensitive cypher query

Is it possible to run a case-insensitive cypher query on neo4j? Try that: http://console.neo4j.org/ When I type into this: start n=node(*) match n-[]->m where (m.name="Neo") return m it returns one row. But when I type into this: start n=node(*)…
gzg
  • 1,469
  • 6
  • 23
  • 39
40
votes
5 answers

What's the Cypher script to delete a node by ID?

In SQL: Delete From Person Where ID = 1; In Cypher, what's the script to delete a node by ID? (Edited: ID = Neo4j's internal Node ID)
Rm558
  • 4,621
  • 3
  • 38
  • 43
1
2 3
99 100