username, count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC http://docs.neo4j.org/chunked/milestone/query-return.html#return-column-alias
count(skill) AS score, collect(skill.name) AS skills ORDER BY score DESC http://docs.neo4j.org/chunked/milestone/query- aggregation.html#aggregation-collect
to any part of the pa3ern in the MATCH clause • Can use AND and OR operators, and NOT func+on – WHERE p.age > 30 AND NOT (s.name = 'Java') • Filter on pa3erns – WHERE (colleague)-[:WORKS_FOR]->(company)
who have similar skills to Ian, but who DO NOT work for the same company – Use query-‐1.txt as a star+ng point – You’ll want to exclude (filter) a path
create-‐2.txt, create-‐3.txt and create-‐4.txt – Acer each opera+on, view the results • What happens if you add or remove proper+es when specifying unique nodes and rela+onships?
amend machine node proper+es, from nam to name: 1. Clean the database 2. Execute setup.txt 3. Write a query that replaces the nam property on all machine nodes with a name property
5 MATCH p = (n:Person{employeeId:754}) <-[:REPORTS_TO*1..5]-() RETURN p All Paths TerminaDng in Person Node MATCH p = (n:Person{employeeId:754}) <-[*]-(:Person) RETURN p http://docs.neo4j.org/chunked/milestone/query-match.html#match-named-path http://docs.neo4j.org/chunked/milestone/query-match.html#match-variable- length-relationships
• You need to traverse the sequence • You may need to iden+fy the beginning or end (first/last, earliest/latest, etc.) • Examples – Event stream – Episodes of a TV series – Job history
• Execute setup.txt – Creates Season 12 node • Execute add-‐node.txt – Creates story node • View the results – MATCH (n) RETURN n • Con+nue adding stories, viewing the results acer each addi+on
returns all the stories in Season 12, in order – Hint: use chained queries – Query 1: find FIRST and LAST nodes – Query 2: named variable-‐length path, from first to last node
background • Using the Java API, you can wait for an index to be populated http://docs.neo4j.org/chunked/milestone/tutorials-java-embedded-new-index.html
• Execute setup.txt • Execute create-‐constraint-‐1.txt – Uniqueness constraint on :Person(username) • Execute create-‐1.txt – CREATE new user with username ‘ian’ • Execute create-‐2.txt – MERGE new user with username ‘ian’
– Drop uniqueness constraint • Execute create-‐1.txt – CREATE new user with username ‘ian’ • Execute constraint-‐1.txt – Uniqueness constraint on :Person(username)