Are these code obsolete in the documentation for data loading?

Database version: 3.5.17

// tag::nodes[]
// Create orders
LOAD CSV WITH HEADERS FROM 'file:///orders.csv' AS row
MERGE (order:Order {orderID: row.OrderID}) 
  ON CREATE SET order.shipName = row.ShipName;

// Create products
LOAD CSV WITH HEADERS FROM 'file:///products.csv' AS row
MERGE (product:Product {productID: row.ProductID}) 
  ON CREATE SET product.productName = row.ProductName, product.unitPrice = toFloat(row.UnitPrice);

// Create suppliers
LOAD CSV WITH HEADERS FROM 'file:///suppliers.csv' AS row
MERGE (supplier:Supplier {supplierID: row.SupplierID}) 
  ON CREATE SET supplier.companyName = row.CompanyName;

// Create employees
LOAD CSV WITH HEADERS FROM 'file:///employees.csv' AS row
MERGE (e:Employee {employeeID:row.EmployeeID}) 
  ON CREATE SET e.firstName = row.FirstName, e.lastName = row.LastName, e.title = row.Title;

// Create categories
LOAD CSV WITH HEADERS FROM 'file:///categories.csv' AS row
MERGE (c:Category {categoryID: row.CategoryID}) 
  ON CREATE SET c.categoryName = row.CategoryName, c.description = row.Description;
// end::nodes[]

// tag::indexes[]
CREATE INDEX product_id FOR (p:Product) ON (p.productID);
CREATE INDEX product_name FOR (p:Product) ON (p.productName);
CREATE INDEX supplier_id FOR (s:Supplier) ON (s.supplierID);
CREATE INDEX employee_id FOR (e:Employee) ON (e.employeeID);
CREATE INDEX category_id FOR (c:Category) ON (c.categoryID);
// end::indexes[]

It executes well untill the 'create index' part. I just executed the Northwind data example without changing anything.

Invalid input 'p': expected whitespace, comment, ON, '=', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, ',', FROM GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 3, column 14 (offset: 15))
"CREATE INDEX product_id FOR (p:Product) ON (p.productID);"

The whole script is supposed to work well to create the database. Right?

Hi lingvisa,

Your "CREATE INDEX"s format are from Neo4j4.0.
In 3.5, Please rewrite the following.

CREATE INDEX ON :Product(productID);
CREATE INDEX ON :Product(productName);
CREATE INDEX ON :Supplier(supplierID);
CREATE INDEX ON :Employee(employeeID);
CREATE INDEX ON :Category(categoryID);

https://neo4j.com/docs/cypher-manual/3.5/schema/index/

Good to know and thanks. BTW, what's the motivation to make the index id explicit in 4.0?

CREATE INDEX product_id FOR (p:Product) ON (p.productID);

Hi,
When deleting, I think "index_name" is easier.

(4.0)
DROP INDEX index_name
(Deprecated syntax)
DROP INDEX ON :Person(age, country)

A follow up question on this example:

According to the documentation, the Merge ... ON MATCH SET command is supposed to find existing nodes and then setting properties on them:
"Merging nodes and setting properties on found nodes."

However, in loading the Orders.csv, I changed Merge ... ON Create Set to Merge ... On Match Set:

LOAD CSV WITH HEADERS FROM 'file:///orders.csv' AS row
MERGE (order:Order {orderID: row.OrderID}) 
  ON MATCH SET order.shipName = row.ShipName, order.customerId = row.CustomerID, order.employeeID = row.EmployeeID, order.shipAddress = row.ShipAddress, order.shipCity = row.ShipCity;

My database starts with nothing. Why does it still work? It can not find any nodes in the graph.

Hi @lingvisa,

Kindly visit MERGE - Cypher Manual.

The query mentioned by you says when first time you insert an OrderID then it will be created in the DB with just one property orderID and next time when you will visit the same orderID once again then the existing node will set/reset other properties like shipName, cutomerId ..... etc.