Adding reviews to Neo4j
To add reviews to Neo4j, we should first create an uniqueness constraint on reviews, as shown:
neo4j-sh (?)$ CREATE CONSTRAINT ON (review:Review) ASSERT review._id IS UNIQUE;
The output of the preceding query is as follows:
+-------------------+ | No data returned. | +-------------------+ Constraints added: 1
To add a review, we can use the following query:
neo4j-sh (?)$ CREATE (review:Review{ _id:"d11f1d66-2331-11e5-ab8f-6c40089a9424", value_for_money: 2, comfort: 3, food: 4, service: 3, stayed_on: 1388670309.210871, created_on: 1391157765.857148, stay_year: 2014, stay_month: 1, stay_day: 2, description:"Was a comfortable stay. Could improve a lot though"}) WITH review MATCH (hotel:Hotel{_id: "19397f48-1c6f-11e5-8014-6c40089a9424"}), (user:User {email: "[email protected]"}) WITH review, user, hotel MERGE (user)-[:WROTE]->(review)-[:FOR_HOTEL]->(hotel);
The output of the preceding query is as follows:
+-------------------+ | No data returned. | +-------------...