We worked on the basis of the Neo4j database and also examples of the regular cypher query commands (Neo4j and Cypher Query Example Part 1).
In part 2 we will try to get into some more complex queries, cypher commands to use with your Neo4j database. A few set of graph you generate from Neo4j Desktop.
Now to get unique elements from the property of a node, we can use the DISTINCT command, so in the below query we have also used the UNWIND clause (we use unwind to transform the list into individual rows), in the below query we load the CSV file with LOAD CSV command and then use UNWIND clause to filter the unique strings only from the rows with DISTINCT command
LOAD CSV with HEADERS FROM "file:///xxxxx/xxxxx/uuuuuuu-Feb-zzzz.csv"
aa expiry unwind expiry. Expiry as x with distinct x
create(expiry:Expiry2019{name:"FUTURES_"+x})
- Now we can use AND, OR operator in the WHERE clause in which we can filter the database based on conditions by on the operator, in case we want to multi-select from a set of variable string type we can use the IN operator in where clause to give multiple options to filter.
match (n:Node1),(d:Node2),(a:Node3),(b:Node4),(c:Node5) ,(e:Node6),(g:Node7),(f:Node8),(h:Node9)
where a.date='01-Jan-2019' and (g.company IN ['AXISBANK','HDFCBANK',NESTLEINDIA] or g.appointmentDate='01-Jan-19')
return n,b,a,c,d,e,g,f,h
- For updating any property of a node, we need to use the SET command to alter or to update the value of the property
match (n:Node1),(a:Node2)
where a.date='01-Jan-2019'
set a.name="Altered"
return n, a
- For fetching data related to the configuration of Neo4j Desktop and Neo4j database we used CALL command and dbms.listConfig() to get a list of configuration, now we use the YIELD sub-class to explicit return selected fields, we have also used db.labels() to get set of labels we have in our database
4.1
call dbms.listConfig()
YIELD name, value
where name starts with 'dbms.memory'
return name,values
4.2
CALL db.labels()
YIELD label
WHERE label CONTAINS 'User'
RETURN count(label) AS numLabels