QuickStart Adding data
Adding data to a graph.
About this task
Now that the schema is created, data may be added using either the traversal method shown in the simple example or DataStax Bulk Loader. The existing data can be dropped from the graph before reloading.
Note the first commands drop all vertex and edge data from the graph, g.V().drop()
and g.E().drop()
, to clear all previously inserted data.
In Studio, be sure to select the Graph view after running the commands to verify the deletions.
As with all queries in Graph, if you are using Gremlin console, alias the graph traversal g to a graph with |
Procedure
-
Adding more data using traversals
-
Drop the data previously loaded:
g.V().drop()
g.E().drop()
-
Load the vertices:
// START-insertAllPersons // person vertices g.addV('person'). property('person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID). property('name', 'Julia CHILD'). property('gender','F'). property('nickname', ['Jay', 'Julia'] as Set). property('country', [['USA', '1912-08-12' as LocalDate, '1944-01-01' as LocalDate] as Tuple, ['Ceylon', '1944-01-01' as LocalDate, '1945-06-01' as LocalDate] as Tuple, ['France', '1948-01-01' as LocalDate, '1950-01-01' as LocalDate] as Tuple, ['USA', '1960-01-01' as LocalDate, '2004-08-13' as LocalDate] as Tuple]). iterate(); g.addV('person'). property('person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID). property('name', 'Simone BECK'). property('gender','F'). property('nickname', ['Simca', 'Simone'] as Set). property('country', [['France', '1904-07-07' as LocalDate, '1991-12-20' as LocalDate] as Tuple]). iterate(); g.addV('person'). property('person_id', '888ad970-0efc-4e2c-b234-b6a71c30efb5' as UUID). property('name', 'Fritz STREIFF'). property('gender','M'). iterate(); g.addV('person'). property('person_id', 'f092107c-0c5c-47e7-917c-c82c7fc2a2493' as UUID). property('name', 'Louisette BERTHOLIE'). property('gender','F'). iterate(); g.addV('person'). property('person_id', 'ef811281-f954-4fd6-ace0-bf67d057771a' as UUID). property('name', 'Patricia SIMON'). property('gender','F'). property('nickname', ['Pat'] as Set). iterate(); g.addV('person'). property('person_id', 'd45c76bc-6f93-4d0e-9d9f-33298dae0524' as UUID). property('name', 'Alice WATERS'). property('gender','F'). iterate(); g.addV('person'). property('person_id', '7f969e16-b81e-4fcd-87c5-1911abbed132' as UUID). property('name', 'Patricia CURTAN'). property('gender','F'). property('nickname', ['Pattie'] as Set). iterate(); g.addV('person'). property('person_id', '01e22ca6-da10-4cf7-8903-9b7e30c25805' as UUID). property('name', 'Kelsie KERR'). property('gender','F'). iterate(); g.addV('person'). property('person_id', 'ad58b8bd-033f-48ee-8f3b-a84f9c24e7de' as UUID). property('name', 'Emeril LAGASSE'). property('gender','M'). iterate(); g.addV('person'). property('person_id', '4ce9caf1-25b8-468e-a983-69bad20c017a' as UUID). property('name', 'James BEARD'). property('gender','M'). property('nickname', ['Jim', 'Jimmy'] as Set). iterate(); // END-insertAllPersons // START-AllPersonReviewers // reviewer vertices g.addV('person'). property('person_id', '46ad98ac-f5c9-4411-815a-f81b3b667921' as UUID). property('name', 'John DOE'). property('gender','M'). property('cal_goal', 1750). property('macro_goal', [10,30,60]). property('badge', ['silver':'2016-01-01' as LocalDate, 'gold':'2017-01-01' as LocalDate]). iterate(); g.addV('person'). property('person_id', '4954d71d-f78c-4a6d-9c4a-f40903edbf3c' as UUID). property('name', 'John SMITH'). property('gender','M'). property('nickname', ['Johnie'] as Set). property('cal_goal', 1800). property('macro_goal', [30,20,50]). iterate(); g.addV('person'). property('person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID). property('name', 'Jane DOE'). property('gender','F'). property('nickname', ['Janie'] as Set). property('cal_goal', 1500). property('macro_goal', [50,15,35]). iterate(); g.addV('person'). property('person_id', 'daa02698-df4f-4436-8855-941774f4c3e0' as UUID). property('name', 'Sharon SMITH'). property('gender','F'). property('cal_goal', 1600). property('macro_goal', [30,20,50]). iterate(); g.addV('person'). property('person_id', '6bda1b37-fe96-42bd-a2db-682073d10c37' as UUID). property('name', 'Betsy JONES'). property('gender','F'). property('cal_goal', 1700). property('macro_goal', [10,50,30]). iterate(); // END-AllPersonReviewers // START-insertAllBook // book vertices g.addV('book'). property('book_id',1001). property('name','The Art of French Cooking, Vol. 1'). property('publish_year',1961). property('category', ['French', 'general', 'cooking'] as Set). iterate(); g.addV('book'). property('book_id', 1002). property('name',"Simca's Cuisine: 100 Classic French Recipes for Every Occasion"). property('publish_year', 1972). property('isbn', '0-394-40152-2'). property('category', ['French', 'cooking'] as Set). iterate(); g.addV('book'). property('book_id', 1003). property('name','The French Chef Cookbook'). property('publish_year', 1968). property('isbn', '0-394-40135-2'). property('category', ['French', 'cooking'] as Set). property('book_discount', '10%'). iterate(); g.addV('book'). property('book_id', 1004). property('name', 'The Art of Simple Food: Notes, Lessons, and Recipes from a Delicious Revolution'). property('publish_year', 2007). property('isbn', '0-307-33679-4'). property('category', ['American', 'cooking', 'simple'] as Set). iterate(); // END-insertAllBook //START-insertAllRecipe // recipe vertices g.addV('recipe'). property('recipe_id', 2001). property('name', 'Beef Bourguignon'). property('cuisine', ['French', 'entree', 'beef'] as Set). property('instructions', 'Braise the beef. Saute the onions and carrots. Add wine and cook in a dutch oven at 425 degrees for 1 hour.'). property('notes', 'Takes a long time to make.'). iterate(); g.addV('recipe'). property('recipe_id', 2002). property('name', 'Rataouille'). property('instructions', 'Peel and cut the egglant. Make sure you cut eggplant into lengthwise slices that are about 1-inch wmyIde, 3-inches long, and 3/8-inch thick'). property('notes', "I've made this 13 times."). iterate(); g.addV('recipe'). property('recipe_id', 2003). property('name', 'Salade Nicoise'). property('instructions', 'Take a salad bowl or platter and line it with lettuce leaves, shortly before serving. Drizzle some olive oil on the leaves and dust them with salt.'). property('notes', ''). iterate(); g.addV('recipe'). property('recipe_id', 2004). property('name', 'Wild Mushroom Stroganoff'). property('instructions', 'Cook the egg noodles according to the package directions and keep warm. Heat 1 1/2 tablespoons of the oliveoil in a large saute pan over medium-high heat.'). property('notes', 'Good for Jan and Bill.'). iterate(); g.addV('recipe'). property('recipe_id', 2005). property('name', 'Spicy Meatloaf'). property('instructions', 'Preheat the oven to 375 degrees F. Cook bacon in a large skillet over medium heat until very crisp and fat has rendered, 8-10 minutes.'). property('notes', ' '). iterate(); g.addV('recipe'). property('recipe_id', 2006) . property('name', 'Oysters Rockefeller'). property('instructions', 'Saute the shallots, celery, herbs, and seasonings in 3 tablespoons of the butter for 3 minutes. Add the watercress and let it wilt.'). property('notes', ' '). iterate(); g.addV('recipe'). property('recipe_id', 2007). property('name', 'Carrot Soup') . property('instructions', 'In a heavy-bottomed pot, melt the butter. When it starts to foam, add the onions and thyme and cook over medium-low heat until tender, about 10 minutes.'). property('notes', 'Quick and easy.'). iterate(); g.addV('recipe'). property('recipe_id', 2008). property('name', 'Roast Pork Loin'). property('instructions', 'The day before, separate the meat from the ribs, stopping about 1 inch before the end of the bones. Season the pork liberally inside and out with salt and pepper and refrigerate overnight.'). property('notes', 'Love this one!'). iterate(); //END-insertAllRecipe // START-insertAllIngred // ingredients vertices g.addV('ingredient'). property('ingred_id', 3001). property('name', 'beef'). iterate(); g.addV('ingredient'). property('ingred_id', 3002). property('name', 'onion'). iterate(); g.addV('ingredient'). property('ingred_id', 3003). property('name', 'mashed garlic'). iterate(); g.addV('ingredient'). property('ingred_id', 3004). property('name', 'butter'). iterate(); g.addV('ingredient'). property('ingred_id', 3005). property('name', 'tomato paste'). iterate(); g.addV('ingredient'). property('ingred_id', 3006). property('name', 'eggplant'). iterate(); g.addV('ingredient'). property('ingred_id', 3007). property('name', 'zucchini'). iterate(); g.addV('ingredient'). property('ingred_id', 3008). property('name', 'olive oil'). iterate(); g.addV('ingredient'). property('ingred_id', 3009). property('name', 'yellow onion'). iterate(); g.addV('ingredient'). property('ingred_id', 3010). property('name', 'green beans'). iterate(); g.addV('ingredient'). property('ingred_id', 3011). property('name', 'tuna'). iterate(); g.addV('ingredient'). property('ingred_id', 3012). property('name', 'tomato'). iterate(); g.addV('ingredient'). property('ingred_id', 3013). property('name', 'hard-boiled egg'). iterate(); g.addV('ingredient'). property('ingred_id', 3014). property('name', 'egg noodles'). iterate(); g.addV('ingredient'). property('ingred_id', 3015). property('name', 'mushrooms'). iterate(); g.addV('ingredient'). property('ingred_id', 3016). property('name', 'bacon'). iterate(); g.addV('ingredient'). property('ingred_id', 3017). property('name', 'celery'). iterate(); g.addV('ingredient'). property('ingred_id', 3018). property('name', 'green bell pepper'). iterate(); g.addV('ingredient'). property('ingred_id', 3019). property('name', 'ground beef'). iterate(); g.addV('ingredient'). property('ingred_id', 3020). property('name', 'pork sausage'). iterate(); g.addV('ingredient'). property('ingred_id', 3021). property('name', 'shallots'). iterate(); g.addV('ingredient'). property('ingred_id', 3022). property('name', 'chervil'). iterate(); g.addV('ingredient'). property('ingred_id', 3023). property('name', 'fennel'). iterate(); g.addV('ingredient'). property('ingred_id', 3024). property('name', 'parsley'). iterate(); g.addV('ingredient'). property('ingred_id', 3025). property('name', 'oyster'). iterate(); g.addV('ingredient'). property('ingred_id', 3026). property('name', 'Pernod'). iterate(); g.addV('ingredient'). property('ingred_id', 3027). property('name', 'thyme'). iterate(); g.addV('ingredient'). property('ingred_id', 3028). property('name', 'carrots'). iterate(); g.addV('ingredient'). property('ingred_id', 3029). property('name', 'chicken broth'). iterate(); g.addV('ingredient'). property('ingred_id', 3030). property('name', 'pork loin'). iterate(); g.addV('ingredient'). property('ingred_id', 3031). property('name', 'red wine'). iterate(); // END-insertAllIngred // START-insertAllMeals // Insert meal vertices g.addV('meal'). property('meal_id', 4001). property('type', 'lunch'). iterate(); g.addV('meal'). property('meal_id', 4002). property('type', 'lunch'). iterate(); g.addV('meal'). property('meal_id', 4003). property('type', 'lunch'). iterate(); g.addV('meal'). property('meal_id', 4004). property('type', 'lunch'). iterate(); g.addV('meal'). property('meal_id', 4005). property('type', 'breakfast'). iterate(); g.addV('meal'). property('meal_id', 4006). property('type', 'snack'). iterate(); g.addV('meal'). property('meal_id', 4007). property('type', 'dinner'). iterate(); g.addV('meal'). property('meal_id', 4008). property('type', 'dinner'). iterate(); // END-insertAllMeals // START-insertAllMealitems // meal_items g.addV('meal_item'). property('item_id',5001). property('name','taco'). property('serv_amt', '1'). property('macro',[15,65,65]). property('calories',650). iterate(); g.addV('meal_item'). property('item_id',5002). property('name','burrito'). property('serv_amt', '1'). property('macro',[15,65,65]). property('calories',1230). iterate(); g.addV('meal_item'). property('item_id',5003). property('name','iced tea'). property('serv_amt', '2 cups'). property('macro',[0,0,0]). property('calories',0). iterate(); // END-insertAllMealitems // START-insertAllFridge_sensor // fridge_sensor vertices g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 100). property('zipcode_id', 55555). property('sensor_id', 001). iterate(); g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 100). property('zipcode_id', 55555). property('sensor_id', 002). iterate(); g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 100). property('zipcode_id', 55555). property('sensor_id', 003). iterate(); g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 200). property('zipcode_id', 55556). property('sensor_id', 001). iterate(); g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 200). property('zipcode_id', 55556). property('sensor_id', 002). iterate(); g.addV('fridge_sensor'). property('state_id', 31). property('city_id', 200). property('zipcode_id', 55556). property('sensor_id', 003). iterate(); g.addV('fridge_sensor'). property('state_id', 45). property('city_id', 300). property('zipcode_id', 66665). property('sensor_id', 001). iterate(); g.addV('fridge_sensor'). property('state_id', 45). property('city_id', 300). property('zipcode_id', 66665). property('sensor_id', 002). iterate(); g.addV('fridge_sensor'). property('state_id', 45). property('city_id', 300). property('zipcode_id', 66665). property('sensor_id', 003). iterate(); // END-insertAllFridge_sensor // START-insertAllLocation // Insert location data g.addV('location'). property('loc_id', 'g1'). property('name', 'Paris'). property('geo_point', 'POINT (2.352222 48.856614)' as Point). iterate(); g.addV('location'). property('loc_id', 'g2'). property('name', 'London'). property('geo_point', 'POINT (-0.127758 51.507351)' as Point). iterate(); g.addV('location'). property('loc_id', 'g3'). property('name', 'Dublin'). property('geo_point', 'POINT (-6.26031 53.349805)' as Point). iterate(); g.addV('location'). property('loc_id', 'g4'). property('name', 'Aachen'). property('geo_point', 'POINT (6.083887 50.775346)' as Point). iterate(); g.addV('location'). property('loc_id', 'g5'). property('name', 'Tokyo'). property('geo_point', 'POINT (139.691706 35.689487)' as Point). iterate(); g.addV('location'). property('loc_id', 'g5'). property('name', 'Tokyo'). property('geo_point', 'POINT (139.691706 35.689487)' as Point). iterate(); g.addV('location'). property('loc_id', 'g6'). property('name', 'New York'). property('geo_point', 'POINT (74.0059 40.7128)' as Point). iterate(); g.addV('location'). property('loc_id', 'g7'). property('name', 'New Orleans'). property('geo_point', 'POINT (90.0715 29.9511)' as Point). iterate(); g.addV('location'). property('loc_id', 'g8'). property('name', 'Los Angeles'). property('geo_point', 'POINT (118.2437 34.0522)' as Point). iterate(); g.addV('location'). property('loc_id', 'g9'). property('name', 'Chicago'). property('geo_point', 'POINT (-87.6298 41.8781136)' as Point). iterate(); g.addV('location'). property('loc_id', 'g10'). property('name', "Jane's house"). property('geo_point', 'POINT (118.5 34.0000)' as Point). iterate(); g.addV('location'). property('loc_id', 'g11'). property('name', "John Smith's place"). property('geo_point', 'POINT (90.0000 30.000)' as Point). iterate(); g.addV('location'). property('loc_id', 'g12'). property('name', "Mary's house"). property('loc_details', [ loc_address: [address1:'215 1st St', city_code:'Winston', state_code:'CA', zip_code:'93002'] as address, telephone: ['530-555-1255', '916-442-2211'] ] as location_details). property('geo_point', 'POINT(-106.372802 35.107546)' as Point). iterate(); g.addV('location'). property('loc_id', 'g13'). property('name', 'Zippy Mart'). property('loc_details', [ loc_address: [address1:'213 F St', city_code:'Winston', state_code:'CA', zip_code:'93001'] as address, telephone: ['530-555-3455', '916-446-2211'] ] as location_details). property('geo_point', 'POINT(-112.347309 34.622238)' as Point). iterate(); g.addV('location'). property('loc_id', 'g14'). property('name', 'Quik Station'). property('loc_details', [ loc_address: [address1:'500 C St', city_code:'Winston', state_code:'CA', zip_code:'93001'] as address, telephone: ['530-555-3454', '916-446-1111'] ] as location_details). property('geo_point', 'POINT(-74.575156 39.339838)' as Point). iterate(); g.addV('location'). property('loc_id', 'g15'). property('name', "Mamma's Grocery"). property('loc_details', [ loc_address: [address1:'1000 A St', city_code:'Winston', state_code:'CA', zip_code:'93001'] as address, telephone: ['530-555-1212', '916-444-3454'] ] as location_details). property('geo_point', 'POINT(-74.423251 42.323255)' as Point). iterate(); g.addV('location'). property('loc_id', 'g100'). property('name', 'test location'). property('loc_details', [ loc_address: [address1:'757 Jay St', city_code:'Arbuckle', state_code:'CA', zip_code:'95691'] as address, telephone: ['530-555-1212', '916-4444-3454'] ] as location_details). property('geo_point', 'POINT (1.352222 48.856614)' as Point). iterate(); // END-insertAllLocation // START-insertAllHome // Insert home data g.addV('home'). property('home_id', 9000). property('name', "Jane's house"). iterate(); g.addV('home'). property('home_id', 9001). property('name', "John Smith's place"). iterate(); g.addV('home'). property('home_id', 9002). property('name', "Mary's house"). iterate(); // END-insertAllHome //START-insertAllStore // Insert all store vertices g.addV('store'). property('store_id', 8001). property('name', 'Zippy Mart'). iterate(); g.addV('store'). property('store_id', 8002). property('name', 'Quik Station'). iterate(); g.addV('store'). property('store_id', 8003). property('name', "Mamma's Grocery"). iterate(); //END-insertAllStore
-
Load the edges. Studio does have a limitation on the number of commands executed in each cell due to serialization to bytecode. To accommodate that limitation, load the following edges in batches in separate cells. Gremlin console does not have the same limitation, so load all edges as shown.
// START-AllFridgeSensorContainsIngred // fridge_sensor contains ingredient edges g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('contains'). property('expire_date', '2017-10-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3001).as('b'). addE('contains'). property('expire_date', '2017-10-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3020).as('b'). addE('contains'). property('expire_date', '2017-08-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('contains'). property('expire_date', '2017-09-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3007).as('b'). addE('contains'). property('expire_date', '2017-07-20' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('contains'). property('expire_date', '2017-11-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3005).as('b'). addE('contains'). property('expire_date', '2017-08-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('contains'). property('expire_date', '2017-09-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('ingredient', 'ingred_id', 3005).as('b'). addE('contains'). property('expire_date', '2017-09-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3010).as('b'). addE('contains'). property('expire_date', '2017-07-15' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('contains'). property('expire_date', '2018-01-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3008).as('b'). addE('contains'). property('expire_date', '2017-07-12' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('contains'). property('expire_date', '2017-09-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('contains'). property('expire_date', '2017-09-09' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('ingredient', 'ingred_id', 3001).as('b'). addE('contains'). property('expire_date', '2017-07-17' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('contains'). property('expire_date', '2017-07-18' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('ingredient', 'ingred_id', 3003).as('b'). addE('contains'). property('expire_date', '2017-11-11' as LocalDate). from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('ingredient', 'ingred_id', 3004).as('b'). addE('contains'). property('expire_date', '2017-09-08' as LocalDate). from('a').to('b'). iterate(); // END-AllFridgeSensorContainsIngred // START-AllFridgeSensorLocatedAtHome // home is_located_at fridge_sensor edges g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('home', 'home_id', 9001).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 004).as('a'). V().has('home', 'home_id', 9001).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('home', 'home_id', 9002).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 100). has('fridge_sensor', 'zipcode_id', 55555). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('home', 'home_id', 9003).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55556). has('fridge_sensor', 'sensor_id', 001).as('a'). V().has('home', 'home_id', 9002).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55556). has('fridge_sensor', 'sensor_id', 002).as('a'). V().has('home', 'home_id', 9003).as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('fridge_sensor', 'state_id', 31). has('fridge_sensor', 'city_id', 200). has('fridge_sensor', 'zipcode_id', 55556). has('fridge_sensor', 'sensor_id', 003).as('a'). V().has('home', 'home_id', 9001).as('b'). addE('is_located_at').from('a').to('b'). iterate(); // END-AllFridgeSensorLocatedAtHome // START-AllHomeLocatedAtLocation // home located_at location edges g.V().has('home', 'home_id', 9001).as('a'). V().has('location', 'loc_id', 'g10').as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('home', 'home_id', 9002).as('a'). V().has('location', 'loc_id', 'g11').as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('home', 'home_id', 9003).as('a'). V().has('location', 'loc_id', 'g12').as('b'). addE('is_located_at').from('a').to('b'). iterate(); // END-AllHomeLocatedAtLocation // START-AllMealIncludesMealItem // meal includes meal_item edges g.V().has('meal', 'meal_id', 4001). has('meal', 'type', 'lunch').as('a'). V().has('meal_item', 'meal_item_id', 5001).as('b'). addE('includes').property('num_serv', 1).from('a').to('b'). iterate(); g.V().has('meal', 'meal_id', 4001).has('meal', 'type', 'lunch').as('a'). V().has('meal_item', 'meal_item_id', 5002).as('b'). addE('includes').property('num_serv', 1).from('a').to('b'). iterate(); g.V().has('meal', 'meal_id', 4001).has('meal', 'type', 'lunch').as('a'). V().has('meal_item', 'meal_item_id', 5003).as('b'). addE('includes').property('num_serv', 2).from('a').to('b'). iterate(); g.V().has('meal', 'meal_id', 4002).has('meal', 'type', 'lunch').as('a'). V().has('meal_item', 'meal_item_id', 5001).as('b'). addE('includes').property('num_serv', 2).from('a').to('b'). iterate(); // END-AllMealIncludesMealItem // START-AllPersonAteMeal // person ate meal edges g.V().has('person', 'person_id', '46ad98ac-f5c9-4411-815a-f81b3b667921' as UUID).as('a'). V().has('type', 'lunch').has('meal', 'meal_id', 4001).as('b'). addE('ate').property('meal_date', '2019-08-20' as LocalDate).from('a').to('b') g.V().has('person', 'person_id', '46ad98ac-f5c9-4411-815a-f81b3b667921' as UUID).as('a'). V().has('type', 'lunch').has('meal', 'meal_id', 4002).as('b'). addE('ate').property('meal_date', '2019-08-20' as LocalDate).from('a').to('b') g.V().has('person', 'person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID).as('a'). V().has('type', 'lunch').has('meal', 'meal_id', 4003).as('b'). addE('ate').property('meal_date', '2019-08-20' as LocalDate).from('a').to('b') g.V().has('person', 'person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID).as('a'). V().has('type', 'lunch').has('meal', 'meal_id', 4004).as('b'). addE('ate').property('meal_date', '2019-08-21' as LocalDate).from('a').to('b') // END-AllPersonAteMeal // START-eatOneMeal g.V().has('person', 'person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID).as('a'). V().has('type', 'lunch').has('meal', 'meal_id', 4004).as('b'). addE('ate').property('meal_date', '2019-08-21' as LocalDate).from('a').to('b') // END-eatOneMeal // START-AllPersonAuthoredBook // person to book edges g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('book', 'book_id', 1001).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID).as('a'). V().has('book', 'book_id', 1001).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'f092107c-0c5c-47e7-917c-c82c7fc2a249' as UUID).as('a'). V().has('book', 'book_id', 1001).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID).as('a'). V().has('book', 'book_id', 1002).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'ef811281-f954-4fd6-ace0-bf67d057771a' as UUID).as('a'). V().has('book', 'book_id', 1002).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('book', 'book_id', 1003).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'd45c76bc-6f93-4d0e-9d9f-33298dae0524' as UUID).as('a'). V().has('book', 'book_id', 1004).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', '7f969e16-b81e-4fcd-87c5-1911abbed132' as UUID).as('a'). V().has('book', 'book_id', 1004).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', '01e22ca6-da10-4cf7-8903-9b7e30c25805' as UUID).as('a'). V().has('book', 'book_id', 1004).as('b'). addE('authored').from('a').to('b'). iterate(); g.V().has('person', 'person_id', '888ad970-0efc-4e2c-b234-b6a71c30efb5' as UUID).as('a'). V().has('book', 'book_id', 1004).as('b'). addE('authored').from('a').to('b'). iterate(); // END-AllPersonAuthoredBook // START-AllPersonCreatedRecipe // person to recipe edges g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('created').property('create_date', '1961-01-01' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('created').property('create_date', '1961-01-01' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('recipe', 'recipe_id', 2002).as('b'). addE('created').property('create_date', '1965-02-02' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('recipe', 'recipe_id', 2003).as('b'). addE('created').property('create_date', '1962-03-03' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'ad58b8bd-033f-48ee-8f3b-a84f9c24e7de' as UUID).as('a'). V().has('recipe', 'recipe_id', 2004).as('b'). addE('created').property('create_date', '2003-04-04' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'ad58b8bd-033f-48ee-8f3b-a84f9c24e7de' as UUID).as('a'). V().has('recipe', 'recipe_id', 2005).as('b'). addE('created').property('create_date', '2000-05-05' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'd45c76bc-6f93-4d0e-9d9f-33298dae0524' as UUID).as('a'). V().has('recipe', 'recipe_id', 2007).as('b'). addE('created').property('create_date', '1995-06-06' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', 'd45c76bc-6f93-4d0e-9d9f-33298dae0524' as UUID).as('a'). V().has('recipe', 'recipe_id', 2008).as('b'). addE('created').property('create_date', '1996-07-07' as LocalDate).from('a').to('b'). iterate() g.V().has('person', 'person_id', '4ce9caf1-25b8-468e-a983-69bad20c017a' as UUID).as('a'). V().has('recipe', 'recipe_id', 2006).as('b'). addE('created').property('create_date', '1970-01-01' as LocalDate).from('a').to('b'). iterate() // START-AllPersonCreatedRecipe // START-AllPersonKnowsPerson // person knows person edges g.V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('a'). V().has('person', 'person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID).as('b'). addE('knows').from('a').to('b'). iterate(); g.V().has('person', 'person_id', 'adb8744c-d015-4d78-918a-d7f062c59e8f' as UUID).as('a') V().has('person', 'person_id', 'e7cd5752-bc0d-4157-a80f-7523add8dbcd' as UUID).as('b') addE('knows').from('a').to('b'). iterate(); // END-AllPersonKnowsPerson // START-AllPersonReviewedRecipe // person_reviewed_recipe g.V().has('person', 'person_id', '46ad98ac-f5c9-4411-815a-f81b3b667921' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2014-01-01' as LocalDate). property('stars', 5). property('comment', 'Pretty tasty!'). from('a').to('b'). iterate() g.V().has('person', 'person_id', '4954d71d-f78c-4a6d-9c4a-f40903edbf3c' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2014-01-23' as LocalDate). property('stars', 4). from('a').to('b'). iterate() g.V().has('person', 'person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2014-02-01' as LocalDate). property('stars', 5). property('comment', 'Yummy!'). from('a').to('b'). iterate() g.V().has('person', 'person_id', 'daa02698-df4f-4436-8855-941774f4c3e0' as UUID).as('a'). V().has('recipe', 'recipe_id', 2001).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2015-12-31' as LocalDate). property('stars', 3). property('comment', 'It was okay.'). from('a').to('b'). iterate() g.V().has('person', 'person_id', '46ad98ac-f5c9-4411-815a-f81b3b667921' as UUID).as('a'). V().has('recipe', 'recipe_id', 2005).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2015-12-31' as LocalDate). property('stars', 4). property('comment', 'Really spicy - be careful!'). from('a').to('b'). iterate() g.V().has('person', 'person_id', 'daa02698-df4f-4436-8855-941774f4c3e0' as UUID).as('a'). V().has('recipe', 'recipe_id', 2005).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2014-07-23' as LocalDate). property('stars', 3). property('comment', 'Too spicy for me. Use less garlic.'). from('a').to('b'). iterate() g.V().has('person', 'person_id', '6c09f656-5aef-46df-97f9-e7f984c9a3d9' as UUID).as('a'). V().has('recipe', 'recipe_id', 2007).as('b'). addE('reviewed'). property('time', '12:00:00' as LocalTime). property('year', '2015-12-30' as LocalDate). property('stars', 5). property('comment', 'Loved this soup! Yummy vegetarian!'). from('a').to('b'). iterate() // END-AllPersonReviewedRecipe // START-insertAllRecipeIncludedInBook // book to recipe edges g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('book', 'book_id', 1001).as('b'). addE('included_in').from('a').to('b'). iterate() g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('book', 'book_id', 1001).as('b'). addE('included_in').from('a').to('b'). iterate() g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('book', 'book_id', 1004).as('b'). addE('included_in').from('a').to('b'). iterate() // END-insertAllRecipeIncludedInBook // meal to recipe edges // The with('allow-filtering') is a shortcut to add the data without an index, but to make queries on these edges, and index will be required. // START-insertAllRecipeIncludedInMeal g.with('allow-filtering').V().has('recipe', 'recipe_id', 2001).as('a'). V().has('meal', 'meal_id', 4001).as('b'). addE('included_in').from('a').to('b'). iterate() g.with('allow-filtering').V().has('recipe', 'recipe_id', 2003).as('a'). V().has('meal', 'meal_id', 4001).as('b'). addE('included_in').from('a').to('b'). iterate() g.with('allow-filtering').V().has('recipe', 'recipe_id', 2007).as('a'). V().has('meal', 'meal_id', 4004).as('b'). addE('included_in').from('a').to('b'). iterate() g.with('allow-filtering').V().has('recipe', 'recipe_id', 2008).as('a'). V().has('meal', 'meal_id', 4004).as('b'). addE('included_in').from('a').to('b'). iterate() // END-insertAllRecipeIncludedInMeal // START-insertAllRecipeIncludesIngred // recipe to ingredient edges g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('ingredient', 'ingred_id', 3001).as('b'). addE('includes').property('amount', '2 lbs').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('includes').property('amount', '1 sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('ingredient', 'ingred_id', 3003).as('b'). addE('includes').property('amount', '2 cloves').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('ingredient', 'ingred_id', 3004).as('b'). addE('includes').property('amount', '3.5 Tbsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2001).as('a'). V().has('ingredient', 'ingred_id', 3005).as('b'). addE('includes').property('amount', '1 Tbsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2002).as('a'). V().has('ingredient', 'ingred_id', 3006).as('b'). addE('includes').property('amount', '1 lb').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2002).as('a'). V().has('ingredient', 'ingred_id', 3007).as('b'). addE('includes').property('amount', '1 lb').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2002).as('a'). V().has('ingredient', 'ingred_id', 3003).as('b'). addE('includes').property('amount', '2 cloves').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2002).as('a'). V().has('ingredient', 'ingred_id', 3008).as('b'). addE('includes').property('amount', '4-6 Tbsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2002).as('a'). V().has('ingredient', 'ingred_id', 3009).as('b'). addE('includes').property('amount', '1 1/2 cups or 1/2 lb thinly sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('ingredient', 'ingred_id', 3008).as('b'). addE('includes').property('amount', '2-3 Tbsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('ingredient', 'ingred_id', 3010).as('b'). addE('includes').property('amount', '1 1/2 lbs blanched, trimmed').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('ingredient', 'ingred_id', 3011).as('b'). addE('includes').property('amount', '8-10 ozs oil-packed, drained and flaked').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('ingredient', 'ingred_id', 3012).as('b'). addE('includes').property('amount', '3 or 4 red, peeled, quartered, cored, and seasoned').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2003).as('a'). V().has('ingredient', 'ingred_id', 3013).as('b'). addE('includes').property('amount', '8 halved lengthwise').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2004).as('a'). V().has('ingredient', 'ingred_id', 3014).as('b'). addE('includes').property('amount', '16 ozs wide').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2004).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('includes').property('amount', '2 lbs wild or exotic, cleaned, stemmed, and sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2004).as('a'). V().has('ingredient', 'ingred_id', 3009).as('b'). addE('includes').property('amount', '1 cup thinly sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('includes').property('amount', '3 ozs diced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('includes').property('amount', '2 cups finely chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3017).as('b'). addE('includes').property('amount', '2 cups finely chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3018).as('b'). addE('includes').property('amount', '1/4 cup finely chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3020).as('b'). addE('includes').property('amount', '3/4 lbs hot').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2005).as('a'). V().has('ingredient', 'ingred_id', 3019).as('b'). addE('includes').property('amount', '1 1/2 lbs chuck').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3021).as('b'). addE('includes').property('amount', '1/4 cup chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3017).as('b'). addE('includes').property('amount', '1/4 cup chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3022).as('b'). addE('includes').property('amount', '1 tsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3023).as('b'). addE('includes').property('amount', '1/3 cup chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3024).as('b'). addE('includes').property('amount', '1/3 cup chopped').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3025).as('b'). addE('includes').property('amount', '1 dozen on the half shell').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2006).as('a'). V().has('ingredient', 'ingred_id', 3026).as('b'). addE('includes').property('amount', '1/3 cup').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('ingredient', 'ingred_id', 3004).as('b'). addE('includes').property('amount', '4 Tbsp').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('includes').property('amount', '2 medium sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('ingredient', 'ingred_id', 3027).as('b'). addE('includes').property('amount', '1 sprig').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('ingredient', 'ingred_id', 3028).as('b'). addE('includes').property('amount', '2 1/2 lbs, peeled and sliced').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2007).as('a'). V().has('ingredient', 'ingred_id', 3029).as('b'). addE('includes').property('amount', '6 cups').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2008).as('a'). V().has('ingredient', 'ingred_id', 3030).as('b'). addE('includes').property('amount', '1 bone-in, 4-rib').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2008).as('a'). V().has('ingredient', 'ingred_id', 3031).as('b'). addE('includes').property('amount', '1/2 cup').from('a').to('b'). iterate(); g.V().has('recipe', 'recipe_id', 2008).as('a'). V().has('ingredient', 'ingred_id', 3029).as('b'). addE('includes').property('amount', '1 cup').from('a').to('b'). iterate(); // END-insertAllRecipeIncludesIngred // START-AllStoreStockedWithIngred // store is_stocked_with ingredient edges g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3001).as('b'). addE('is_stocked_with'). property('expire_date', '2017-01-10' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('is_stocked_with'). property('expire_date', '2017-01-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3004).as('b'). addE('is_stocked_with'). property('expire_date', '2017-06-23' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3001).as('b'). addE('is_stocked_with'). property('expire_date', '2017-06-09' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('is_stocked_with'). property('expire_date', '2017-11-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('is_stocked_with'). property('expire_date', '2017-11-11' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8001).as('a'). V().has('ingredient', 'ingred_id', 3020).as('b'). addE('is_stocked_with'). property('expire_date', '2017-12-12' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3003).as('b'). addE('is_stocked_with'). property('expire_date', '2017-12-12' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3005).as('b'). addE('is_stocked_with'). property('expire_date', '2017-01-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3007).as('b'). addE('is_stocked_with'). property('expire_date', '2017-05-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3009).as('b'). addE('is_stocked_with'). property('expire_date', '2017-05-02' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3011).as('b'). addE('is_stocked_with'). property('expire_date', '2017-02-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3015).as('b'). addE('is_stocked_with'). property('expire_date', '2017-02-02' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3016).as('b'). addE('is_stocked_with'). property('expire_date', '2017-10-17' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('ingredient', 'ingred_id', 3019).as('b'). addE('is_stocked_with'). property('expire_date', '2017-10-10' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3002).as('b'). addE('is_stocked_with'). property('expire_date', '2017-04-03' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3007).as('b'). addE('is_stocked_with'). property('expire_date', '2017-03-04' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3008).as('b'). addE('is_stocked_with'). property('expire_date', '2017-07-30' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3012).as('b'). addE('is_stocked_with'). property('expire_date', '2017-09-30' as LocalDate). from('a').to('b'). iterate(); // duplication?? g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3008).as('b'). addE('is_stocked_with'). property('expire_date', '2017-02-02' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3006).as('b'). addE('is_stocked_with'). property('expire_date', '2017-01-01' as LocalDate). from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('ingredient', 'ingred_id', 3004).as('b'). addE('is_stocked_with'). property('expire_date', '2017-04-25' as LocalDate). from('a').to('b'). iterate(); // END-AllStoreStockedWithIngred // START-AllStoreLocatedAtLocation // store is_located_at location edges g.V().has('store', 'store_id', 8001).as('a'). V().has('location', 'loc_id', 'g13').as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8002).as('a'). V().has('location', 'loc_id', 'g14').as('b'). addE('is_located_at').from('a').to('b'). iterate(); g.V().has('store', 'store_id', 8003).as('a'). V().has('location', 'loc_id', 'g15').as('b'). addE('is_located_at').from('a').to('b'). iterate(); // END-AllStoreLocatedAtLocation
-
In Studio, run the following command to display all the data:
dev.with('label-warning', false).V()
and additionally, if using Gremlin console, run the following command to see the edges:
dev.with('label-warning', false).E()
Studio will display both vertices and edges when the vertices are queried.
In Gremlin console, run the following commands to view the results, similar to the sample shown here:
// A series of returns for vertices and edges will mark the successful completion gremlin> dev.V() ==>v[dseg:/person/4ce9caf1-25b8-468e-a983-69bad20c017a] ==>v[dseg:/person/888ad970-0efc-4e2c-b234-b6a71c30efb5] ==>v[dseg:/person/4954d71d-f78c-4a6d-9c4a-f40903edbf3c] ==>v[dseg:/person/01e22ca6-da10-4cf7-8903-9b7e30c25805] ==>v[dseg:/person/6c09f656-5aef-46df-97f9-e7f984c9a3d9] ==>v[dseg:/person/daa02698-df4f-4436-8855-941774f4c3e0] ==>v[dseg:/person/d45c76bc-6f93-4d0e-9d9f-33298dae0524] ==>v[dseg:/person/adb8744c-d015-4d78-918a-d7f062c59e8f] ==>v[dseg:/person/e7cd5752-bc0d-4157-a80f-7523add8dbcd] ==>v[dseg:/person/f092107c-0c5c-47e7-917c-82c7fc2a2493] ==>v[dseg:/person/ad58b8bd-033f-48ee-8f3b-a84f9c24e7de] ==>v[dseg:/person/6bda1b37-fe96-42bd-a2db-682073d10c37] ==>v[dseg:/person/7f969e16-b81e-4fcd-87c5-1911abbed132] ==>v[dseg:/person/ef811281-f954-4fd6-ace0-bf67d057771a] ==>v[dseg:/person/46ad98ac-f5c9-4411-815a-f81b3b667921] ==>v[dseg:/book/1001] ==>v[dseg:/book/1002] gremlin> dev.E() ==>e[dseg:/person-authored-book/adb8744c-d015-4d78-918a-d7f062c59e8f/1001][dseg:/person/adb8744c-d015-4d78-918a-d7f062c59e8f-authored->dseg:/book/1001] ==>e[dseg:/person-authored-book/adb8744c-d015-4d78-918a-d7f062c59e8f/1002][dseg:/person/adb8744c-d015-4d78-918a-d7f062c59e8f-authored->dseg:/book/1002] ==>e[dseg:/person-authored-book/e7cd5752-bc0d-4157-a80f-7523add8dbcd/1001][dseg:/person/e7cd5752-bc0d-4157-a80f-7523add8dbcd-authored->dseg:/book/1001] ==>e[dseg:/person-authored-book/ef811281-f954-4fd6-ace0-bf67d057771a/1002][dseg:/person/ef811281-f954-4fd6-ace0-bf67d057771a-authored->dseg:/book/1002] ==>e[dseg:/person-knows-person/e7cd5752-bc0d-4157-a80f-7523add8dbcd/adb8744c-d015-4d78-918a-d7f062c59e8f][dseg:/person/e7cd5752-bc0d-4157-a80f-7523add8dbcd-knows->dseg:/person/adb8744c-d015-4d78-918a-d7f062c59e8f]
-
If a vertex count is run, there is now a higher count of 100 vertices. Run the vertex count again:
g.V().count()
-
Similarly, the edge count can be run, to discover the higher edge count of 112:
g.E().count()
-
Adding more data using the DataStax Bulk Loader (optional)
-
Data can be loaded with DataStax Bulk Loader, a standalone command-line tool, using CSV or JSON input files (see the next cell for CSV files that will be loaded). The following commands should be run from a terminal on a cluster node that has
dsbulk
installed. -
Load data to
person
table from a CSV file with a pipe delimiter and allow missing field values:CSV data file located in data/vertices/person.csv containing:
person_id|name|gender|nickname|cal_goal|macro_goal|badge|country e7cd5752-bc0d-4157-a80f-7523add8dbcd|Julia CHILD|F|'Jay','Julia'||||[['USA', '1912-08-12', '1944-01-01'], ['Ceylon', '1944-01-01', '1945-06-01'], ['France', '1948-01-01', '1960-01-01'], ['USA','1960-01-01', '2004-08-13']] adb8744c-d015-4d78-918a-d7f062c59e8f|Simone BECK|F|'Simca','Simone'||||[['France', '1904-07-07', '1991-12-20']] 888ad970-0efc-4e2c-b234-b6a71c30efb5|Fritz STREIFF|M||||| f092107c-0c5c-47e7-917c-c82c7fc2a249|Louisette BERTHOLIE|F||||| ef811281-f954-4fd6-ace0-bf67d057771a|Patricia SIMON|F|'Pat'|||| d45c76bc-6f93-4d0e-9d9f-33298dae0524|Alice WATERS|F||||| 7f969e16-b81e-4fcd-87c5-1911abbed132|Patricia CURTAN|F|'Pattie'|||| 01e22ca6-da10-4cf7-8903-9b7e30c25805|Kelsie KERR|F||||| ad58b8bd-033f-48ee-8f3b-a84f9c24e7de|Emeril LAGASSE|M||||| 4ce9caf1-25b8-468e-a983-69bad20c017a|James BEARD|M|'Jim', 'Jimmy'|||| 65fd73f7-0e06-49af-abd6-0725dc64737d|John DOE|M|'Johnny'|1750|10,30,60|'silver':'2016-01-01', 'gold':'2017-02-01'| 3b3e89f4-5ca2-437e-b8e8-fe7c5e580068|John SMITH|M|'Johnnie'|1800|30,20,50|| 9b564212-9544-4f85-af36-57615e927f89|Jane DOE|F|'Janie'|1500|50,15,35|| ba6a6766-beae-4a35-965b-6f3878581702|Sharon SMITH|F||1600|30,20,50|| a3e7ab29-2ac9-4abf-9d4a-285bf2714a9f|Betsy JONES|F||1700|10,50,30||
and run the dsbulk command:
dsbulk load --schema.keyspace food_qs --schema.table person -url data/vertices/person.csv -delim '|' --schema.allowMissingFields true
-
Load data to
book
table from a CSV file with a pipe delimiter, allow missing field values, and identifying thefield->columns
with schema mapping:CSV data file located in data/vertices/book.csv containing:
book_id|name|publish_year|isbn 1001|The Art of French Cooking, Vol. 1|1961| 1002|Simca's Cuisine: 100 Classic French Recipes for Every Occasion|1972|0-394-40152-2 1003|The French Chef Cookbook|1968|0-394-40135-2 1004|The Art of Simple Food: Notes, Lessons, and Recipes from a Delicious Revolution|2007|0-307-33679-4
and run the dsbulk command:
dsbulk load -k food_qs -t book \ -url data/vertices/book.csv \ --schema.mapping '0=book_id, 1=name, 2=publish_year 3=isbn' \ -delim '|' \ --schema.allowMissingFields true
-
Load data to
person_authored_book
table from a CSV file with a pipe delimiter, allow missing field values, and map CSV file positions to named columns in the table:CSV data file located in data/edges/person_authored_book.csv containing:
person_id|book_id bb6d7af7-f674-4de7-8b4c-c0fdcdaa5cca|1001 adb8744c-d015-4d78-918a-d7f062c59e8f|1001 f092107c-0c5c-47e7-917c-c82c7fc2a249|1001 adb8744c-d015-4d78-918a-d7f062c59e8f|1002 ef811281-f954-4fd6-ace0-bf67d057771a|1002 bb6d7af7-f674-4de7-8b4c-c0fdcdaa5cca|1003 d45c76bc-6f93-4d0e-9d9f-33298dae0524|1004 7f969e16-b81e-4fcd-87c5-1911abbed132|1004 01e22ca6-da10-4cf7-8903-9b7e30c25805|1004 888ad970-0efc-4e2c-b234-b6a71c30efb5|1004
and run the dsbulk command:
dsbulk load -k food_qs -t person_authored_book \ -url data/edges/person\_authored\_book.csv \ -m '0=lastname, 1=person_id, 2=person_name, 3=book_id 4=book_name' \ -delim '|' \ --schema.allowMissingFields true
DataStax Bulk Loader is very versatile, and should be explored in its entirety.