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
30
votes
3 answers

How to get node's id with cypher request?

I'm using neo4j and making executing this query: MATCH (n:Person) RETURN n.name LIMIT 5 I'm getting the names but i need the ids too. Please help!
Aleksandrenko
  • 2,987
  • 6
  • 28
  • 34
28
votes
3 answers

Neo4j super node issue - fanning out pattern

I'm new to the Graph Database scene, looking into Neo4j and learning Cypher, we're trying to model a graph database, it's a fairly simple one, we got users, and we got movies, users can VIEW movies, RATE movies, create playlists and playlists can…
Eek
  • 1,740
  • 1
  • 15
  • 24
27
votes
2 answers

How to return relationship type with Neo4J's Cypher queries?

I am trying to get the relationship type of a very simple Cypher query, like the following MATCH (n)-[r]-(m) RETURN n, r, m; Unfortunately this return an empty object for r. This is troublesome since I can't distinguish between the different types…
F Lekschas
  • 12,481
  • 10
  • 60
  • 72
27
votes
1 answer

How to get the label of a relationship

If I have the cypher query MATCH (a)-[r]->(b) I can get the labels of a and b fine line so MATCH (a)-[r]->(b) RETURN labels(a), labels(b) But when I want the label of r using the same syntax MATCH (a)-[r]->(b) RETURN labels(r) I get Type…
Christopher Hackett
  • 6,042
  • 2
  • 31
  • 41
27
votes
8 answers

neo4j how to drop all constraints

Is there a cypher command to drop all constraints? I know I can drop specific constraints. DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE However I want to clear all constraints as part of teardown after testing. Can't find anything in…
AJcodez
  • 31,780
  • 20
  • 84
  • 118
25
votes
1 answer

Find neo4j nodes with more than one incoming relationship

I'm trying to find all the nodes with more than one incoming relationship. Given this data: a-[has]->b a-[has]->c d-[has]->b So, I'm looking for a query that returns 'b', because it has more that one incoming. This query is close. It returns 'a'…
SteveS
  • 536
  • 1
  • 6
  • 10
25
votes
4 answers

how do I delete duplicate relationships between two nodes with cypher?

When I run this query: START n1=node(7727), n2=node(7730) MATCH n1-[r:SKILL]->n2 RETURN r it gives me a list of duplicate relationships that I have between the two nodes. what do I add to the cypher query to iterate over the relationship to keep…
priyolahiri
  • 668
  • 1
  • 5
  • 10
25
votes
3 answers

Neo4j: Step by Step to create an automatic index

I am creating a new Neo4j database. I have a type of node called User and I would like an index on the properties of user Identifier and EmailAddress. How does one go setting up an index when the database is new? I have noticed in the…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
24
votes
1 answer

Neo4j: label vs. indexed property?

Suppose you're Twitter, and: You have (:User) and (:Tweet) nodes; Tweets can get flagged; and You want to query the list of flagged tweets currently awaiting moderation. You can either add a label for those tweets, e.g. :AwaitingModeration, or add…
Aseem Kishore
  • 10,404
  • 10
  • 51
  • 56
24
votes
1 answer

How to count the number of relationships in Neo4j

I am using Neo4j 2.0 and using the following query to find out the count of number of a particular relationship from a particular node. I have to check the number of relationships named "LIVES" from a particular node PERSON. My query is: match…
poorvank
  • 7,524
  • 19
  • 60
  • 102
24
votes
4 answers

Multiple unrelated queries in Neo4j Cypher?

Does http://localhost:7474/browser/ not support multiple unrelated queries? This code: MATCH (a {cond:'1'}), (b {cond:'x'}) CREATE a-[:rel]->b MATCH (a {cond:'2'}), (b {cond:'y'}) CREATE a-[:rel]->b MATCH (a {cond:'3'}), (b {cond:'z'}) CREATE…
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
24
votes
2 answers

Neo4j: How do I delete a specific relationship with cypher?

Lets say, I have an user: CREATE (n { name: 'Tamil' }) and 2 roles: CREATE (n { name: 'developer' } ) CREATE (n { name: 'tester' } ) Then, I make relationship between the user & each of the 2 roles. CYPHER 1.9 START a = node(*), b = node(*)…
user405398
23
votes
3 answers

How to get all connected nodes in neo4j

I want to get list of all connected nodes starting from node 0 as shown in the diagram
chetan dev
  • 611
  • 2
  • 6
  • 16
23
votes
2 answers

How to hide unwanted relationships between nodes in Neo4j

I'm new in Neo4j and I have a weird requirement. I have some node CREATE (a:node {title:1}) CREATE (b:node {title:2}) CREATE (c:node {title:3}) CREATE (d:node {title:4}) and multiple relationships between them: CREATE…
kishoredbn
  • 2,007
  • 4
  • 28
  • 47
23
votes
2 answers

How can I make a string contain filter on Neo4j Cypher

I need to make a string contain filter in Neo4J. The idea is simple. A good example is that I need to retrieve from a database of persons all the people that contain in his name the car substring. How can I do this?
chfumero
  • 1,137
  • 2
  • 13
  • 26