From 32efb1f05f5687673d423b00324973ba385fcd79 Mon Sep 17 00:00:00 2001 From: crism87 <6799664+crism87@users.noreply.github.com> Date: Fri, 6 Aug 2021 00:32:23 -0700 Subject: [PATCH] crisgrammarRevision --- example_output/AqlPart2Tutorial_output.ipynb | 978 ++++++++++--------- example_output/ArangoDBUniversity | 1 + 2 files changed, 501 insertions(+), 478 deletions(-) create mode 160000 example_output/ArangoDBUniversity diff --git a/example_output/AqlPart2Tutorial_output.ipynb b/example_output/AqlPart2Tutorial_output.ipynb index dd5c5ca..37f2207 100644 --- a/example_output/AqlPart2Tutorial_output.ipynb +++ b/example_output/AqlPart2Tutorial_output.ipynb @@ -1,11 +1,10 @@ { "nbformat": 4, - "nbformat_minor": 0, + "nbformat_minor": 2, "metadata": { "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" + "name": "python3", + "display_name": "Python 3.8.9 64-bit" }, "language_info": { "codemirror_mode": { @@ -17,50 +16,49 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.8.9" }, "colab": { "name": "AqlPart2Tutorial.ipynb", "provenance": [] + }, + "interpreter": { + "hash": "ef0271e88afbecb3a580395856f963597abfc65a9ed5be9ab1e92f931e459d82" } }, "cells": [ { "cell_type": "markdown", + "source": [ + "![arangodb](https://github.com/joerg84/ArangoDBUniversity/blob/master/img/ArangoDB_logo.png?raw=1)" + ], "metadata": { "id": "3um03E2J5sST", "colab_type": "text" - }, - "source": [ - "![arangodb](https://github.com/joerg84/ArangoDBUniversity/blob/master/img/ArangoDB_logo.png?raw=1)" - ] + } }, { "cell_type": "markdown", + "source": [ + "# AQL Tutorial Part 2" + ], "metadata": { "id": "jyDOKQYd5sSU", "colab_type": "text" - }, - "source": [ - "# AQL Tutorial Part 2" - ] + } }, { "cell_type": "markdown", + "source": [ + "\"Open" + ], "metadata": { "id": "6mGTM4-G5sSU", "colab_type": "text" - }, - "source": [ - "\"Open" - ] + } }, { "cell_type": "markdown", - "metadata": { - "id": "Ks7u2T0b5sSV", - "colab_type": "text" - }, "source": [ "In the [first part of this tutorial](https://colab.research.google.com/github/joerg84/ArangoDBUniversity/blob/master/AqlCrudTutorial.ipynb) we have looked at basic CRUD queries. In this second part, we will look at some more advanced AQL features:\n", "\n", @@ -70,183 +68,198 @@ "\n", "\n", "Recall, that in addition to the python interface, you can interact with ArangoDB using its web interface to manage collections and execute the queries." - ] + ], + "metadata": { + "id": "Ks7u2T0b5sSV", + "colab_type": "text" + } }, { "cell_type": "markdown", + "source": [ + "# Setup " + ], "metadata": { "id": "3kL43uOK5sSV", "colab_type": "text" - }, - "source": [ - "# Setup " - ] + } }, { "cell_type": "markdown", + "source": [ + "Before getting started with ArangoDB we need to prepare our environment and create a temporary database on ArangoDB's managed Service Oasis." + ], "metadata": { "id": "2j8mWEZL5sSW", "colab_type": "text" - }, - "source": [ - "Before getting started with ArangoDB we need to prepare our environment and create a temporary database on ArangoDB's managed Service Oasis." - ] + } }, { "cell_type": "code", + "execution_count": 1, + "source": [ + "%%capture\r\n", + "!git clone https://github.com/joerg84/ArangoDBUniversity.git\r\n", + "!rsync -av ArangoDBUniversity/ ./ --exclude=.git\r\n", + "!pip3 install pyarango\r\n", + "!pip3 install \"python-arango>=5.0\"" + ], + "outputs": [], "metadata": { "id": "dnG-GYAL5sSW", "colab_type": "code", "colab": {} - }, - "source": [ - "%%capture\n", - "!git clone https://github.com/joerg84/ArangoDBUniversity.git\n", - "!rsync -av ArangoDBUniversity/ ./ --exclude=.git\n", - "!pip3 install pyarango\n", - "!pip3 install \"python-arango>=5.0\"" - ], - "execution_count": 0, - "outputs": [] + } }, { "cell_type": "code", + "execution_count": 2, + "source": [ + "import json\r\n", + "import requests\r\n", + "import sys\r\n", + "import oasis\r\n", + "import time\r\n", + "\r\n", + "from pyArango.connection import *\r\n", + "from arango import ArangoClient" + ], + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "D:\\python38\\lib\\site-packages\\requests\\__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (3.0.4) doesn't match a supported version!\n", + " warnings.warn(\"urllib3 ({}) or chardet ({}) doesn't match a supported \"\n" + ] + }, + { + "output_type": "error", + "ename": "ModuleNotFoundError", + "evalue": "No module named 'oasis'", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_13684/3169597068.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mrequests\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0moasis\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'oasis'" + ] + } + ], "metadata": { "id": "LUX7q9l45sSa", "colab_type": "code", "colab": {} - }, - "source": [ - "import json\n", - "import requests\n", - "import sys\n", - "import oasis\n", - "import time\n", - "\n", - "from pyArango.connection import *\n", - "from arango import ArangoClient" - ], - "execution_count": 0, - "outputs": [] + } }, { "cell_type": "markdown", + "source": [ + "Create the temporary database:" + ], "metadata": { "id": "Rq2BmYBv5sSc", "colab_type": "text" - }, - "source": [ - "Create the temporary database:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "u4KxZrx_5sSd", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 51 - }, - "outputId": "10b57991-e02b-451b-f075-6b2eaf7d989f" - }, + "execution_count": null, "source": [ - "# Retrieve tmp credentials from ArangoDB Tutorial Service\n", - "login = oasis.getTempCredentials(tutorialName=\"AqlPart2Tutorial\", credentialProvider='https://tutorials.arangodb.cloud:8529/_db/_system/tutorialDB/tutorialDB')\n", - "\n", - "# Connect to the temp database\n", - "conn = oasis.connect(login)\n", + "# Retrieve tmp credentials from ArangoDB Tutorial Service\r\n", + "login = oasis.getTempCredentials(tutorialName=\"AqlPart2Tutorial\", credentialProvider='https://tutorials.arangodb.cloud:8529/_db/_system/tutorialDB/tutorialDB')\r\n", + "\r\n", + "# Connect to the temp database\r\n", + "conn = oasis.connect(login)\r\n", "db = conn[login[\"dbName\"]] " ], - "execution_count": 3, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Requesting new temp credentials.\n", "Temp database ready to use.\n" - ], - "name": "stdout" + ] } - ] - }, - { - "cell_type": "code", + ], "metadata": { - "id": "COnpj8Zd5sSf", + "id": "u4KxZrx_5sSd", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", - "height": 85 + "height": 51 }, - "outputId": "ab9c0c78-6527-4326-9af8-b3d73eb63759" - }, + "outputId": "10b57991-e02b-451b-f075-6b2eaf7d989f" + } + }, + { + "cell_type": "code", + "execution_count": null, "source": [ - "print(\"https://{}:{}\".format(login[\"hostname\"], login[\"port\"]))\n", - "print(\"Username: \" + login[\"username\"])\n", - "print(\"Password: \" + login[\"password\"])\n", + "print(\"https://{}:{}\".format(login[\"hostname\"], login[\"port\"]))\r\n", + "print(\"Username: \" + login[\"username\"])\r\n", + "print(\"Password: \" + login[\"password\"])\r\n", "print(\"Database: \" + login[\"dbName\"])" ], - "execution_count": 4, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "https://tutorials.arangodb.cloud:8529\n", "Username: TUT08ov1y4zr7lqbzjazxfn54l\n", "Password: TUTs85q9qv6qzlaqxmyg8bvze\n", "Database: TUTmhrp5uc2yude9nm189h7\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "COnpj8Zd5sSf", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 85 + }, + "outputId": "ab9c0c78-6527-4326-9af8-b3d73eb63759" + } }, { "cell_type": "markdown", + "source": [ + "Feel free to use to above URL to checkout the UI!" + ], "metadata": { "id": "iFC6H1y15sSh", "colab_type": "text" - }, - "source": [ - "Feel free to use to above URL to checkout the UI!" - ] + } }, { "cell_type": "markdown", + "source": [ + "## Import Data" + ], "metadata": { "id": "G76dWKz15sSi", "colab_type": "text" - }, - "source": [ - "## Import Data" - ] + } }, { "cell_type": "markdown", + "source": [ + "We will work with the same dataset as in the [first part of this tutorial](https://colab.research.google.com/github/joerg84/ArangoDBUniversity/blob/master/AqlCrudTutorial.ipynb). So let us quickly import that into our temporary database. " + ], "metadata": { "id": "VpaZBUiM5sSi", "colab_type": "text" - }, - "source": [ - "We will work with the same dataset as in the [first part of this tutorial](https://colab.research.google.com/github/joerg84/ArangoDBUniversity/blob/master/AqlCrudTutorial.ipynb). So let us quickly import that into our temporary database. " - ] + } }, { "cell_type": "code", - "metadata": { - "id": "N-fFr4Pw5sSj", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 34 - }, - "outputId": "a99ad279-2824-4682-a2ef-caa1096f0742" - }, + "execution_count": null, "source": [ - "# Create the Characters Collection \n", + "# Create the Characters Collection \r\n", "db.createCollection(name=\"Characters\")" ], - "execution_count": 5, "outputs": [ { "output_type": "execute_result", @@ -260,74 +273,74 @@ }, "execution_count": 5 } - ] - }, - { - "cell_type": "code", + ], "metadata": { - "id": "QU3wB0uA5sSl", + "id": "N-fFr4Pw5sSj", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, - "outputId": "633d17bf-63a1-42be-abae-cf498ad0733b" - }, + "outputId": "a99ad279-2824-4682-a2ef-caa1096f0742" + } + }, + { + "cell_type": "code", + "execution_count": null, "source": [ - "insert_query = \"\"\"\n", - "LET data = [\n", - " { \"name\": \"Ned\", \"surname\": \"Stark\", \"alive\": true, \"age\": 41, \"traits\": [\"A\",\"H\",\"C\",\"N\",\"P\"] },\n", - " { \"name\": \"Robert\", \"surname\": \"Baratheon\", \"alive\": false, \"traits\": [\"A\",\"H\",\"C\"] },\n", - " { \"name\": \"Jaime\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 36, \"traits\": [\"A\",\"F\",\"B\"] },\n", - " { \"name\": \"Catelyn\", \"surname\": \"Stark\", \"alive\": false, \"age\": 40, \"traits\": [\"D\",\"H\",\"C\"] },\n", - " { \"name\": \"Cersei\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 36, \"traits\": [\"H\",\"E\",\"F\"] },\n", - " { \"name\": \"Daenerys\", \"surname\": \"Targaryen\", \"alive\": true, \"age\": 16, \"traits\": [\"D\",\"H\",\"C\"] },\n", - " { \"name\": \"Jorah\", \"surname\": \"Mormont\", \"alive\": false, \"traits\": [\"A\",\"B\",\"C\",\"F\"] },\n", - " { \"name\": \"Petyr\", \"surname\": \"Baelish\", \"alive\": false, \"traits\": [\"E\",\"G\",\"F\"] },\n", - " { \"name\": \"Viserys\", \"surname\": \"Targaryen\", \"alive\": false, \"traits\": [\"O\",\"L\",\"N\"] },\n", - " { \"name\": \"Jon\", \"surname\": \"Snow\", \"alive\": true, \"age\": 16, \"traits\": [\"A\",\"B\",\"C\",\"F\"] },\n", - " { \"name\": \"Sansa\", \"surname\": \"Stark\", \"alive\": true, \"age\": 13, \"traits\": [\"D\",\"I\",\"J\"] },\n", - " { \"name\": \"Arya\", \"surname\": \"Stark\", \"alive\": true, \"age\": 11, \"traits\": [\"C\",\"K\",\"L\"] },\n", - " { \"name\": \"Robb\", \"surname\": \"Stark\", \"alive\": false, \"traits\": [\"A\",\"B\",\"C\",\"K\"] },\n", - " { \"name\": \"Theon\", \"surname\": \"Greyjoy\", \"alive\": true, \"age\": 16, \"traits\": [\"E\",\"R\",\"K\"] },\n", - " { \"name\": \"Bran\", \"surname\": \"Stark\", \"alive\": true, \"age\": 10, \"traits\": [\"L\",\"J\"] },\n", - " { \"name\": \"Joffrey\", \"surname\": \"Baratheon\", \"alive\": false, \"age\": 19, \"traits\": [\"I\",\"L\",\"O\"] },\n", - " { \"name\": \"Sandor\", \"surname\": \"Clegane\", \"alive\": true, \"traits\": [\"A\",\"P\",\"K\",\"F\"] },\n", - " { \"name\": \"Tyrion\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 32, \"traits\": [\"F\",\"K\",\"M\",\"N\"] },\n", - " { \"name\": \"Khal\", \"surname\": \"Drogo\", \"alive\": false, \"traits\": [\"A\",\"C\",\"O\",\"P\"] },\n", - " { \"name\": \"Tywin\", \"surname\": \"Lannister\", \"alive\": false, \"traits\": [\"O\",\"M\",\"H\",\"F\"] },\n", - " { \"name\": \"Davos\", \"surname\": \"Seaworth\", \"alive\": true, \"age\": 49, \"traits\": [\"C\",\"K\",\"P\",\"F\"] },\n", - " { \"name\": \"Samwell\", \"surname\": \"Tarly\", \"alive\": true, \"age\": 17, \"traits\": [\"C\",\"L\",\"I\"] },\n", - " { \"name\": \"Stannis\", \"surname\": \"Baratheon\", \"alive\": false, \"traits\": [\"H\",\"O\",\"P\",\"M\"] },\n", - " { \"name\": \"Melisandre\", \"alive\": true, \"traits\": [\"G\",\"E\",\"H\"] },\n", - " { \"name\": \"Margaery\", \"surname\": \"Tyrell\", \"alive\": false, \"traits\": [\"M\",\"D\",\"B\"] },\n", - " { \"name\": \"Jeor\", \"surname\": \"Mormont\", \"alive\": false, \"traits\": [\"C\",\"H\",\"M\",\"P\"] },\n", - " { \"name\": \"Bronn\", \"alive\": true, \"traits\": [\"K\",\"E\",\"C\"] },\n", - " { \"name\": \"Varys\", \"alive\": true, \"traits\": [\"M\",\"F\",\"N\",\"E\"] },\n", - " { \"name\": \"Shae\", \"alive\": false, \"traits\": [\"M\",\"D\",\"G\"] },\n", - " { \"name\": \"Talisa\", \"surname\": \"Maegyr\", \"alive\": false, \"traits\": [\"D\",\"C\",\"B\"] },\n", - " { \"name\": \"Gendry\", \"alive\": false, \"traits\": [\"K\",\"C\",\"A\"] },\n", - " { \"name\": \"Ygritte\", \"alive\": false, \"traits\": [\"A\",\"P\",\"K\"] },\n", - " { \"name\": \"Tormund\", \"surname\": \"Giantsbane\", \"alive\": true, \"traits\": [\"C\",\"P\",\"A\",\"I\"] },\n", - " { \"name\": \"Gilly\", \"alive\": true, \"traits\": [\"L\",\"J\"] },\n", - " { \"name\": \"Brienne\", \"surname\": \"Tarth\", \"alive\": true, \"age\": 32, \"traits\": [\"P\",\"C\",\"A\",\"K\"] },\n", - " { \"name\": \"Ramsay\", \"surname\": \"Bolton\", \"alive\": true, \"traits\": [\"E\",\"O\",\"G\",\"A\"] },\n", - " { \"name\": \"Ellaria\", \"surname\": \"Sand\", \"alive\": true, \"traits\": [\"P\",\"O\",\"A\",\"E\"] },\n", - " { \"name\": \"Daario\", \"surname\": \"Naharis\", \"alive\": true, \"traits\": [\"K\",\"P\",\"A\"] },\n", - " { \"name\": \"Missandei\", \"alive\": true, \"traits\": [\"D\",\"L\",\"C\",\"M\"] },\n", - " { \"name\": \"Tommen\", \"surname\": \"Baratheon\", \"alive\": true, \"traits\": [\"I\",\"L\",\"B\"] },\n", - " { \"name\": \"Jaqen\", \"surname\": \"H'ghar\", \"alive\": true, \"traits\": [\"H\",\"F\",\"K\"] },\n", - " { \"name\": \"Roose\", \"surname\": \"Bolton\", \"alive\": true, \"traits\": [\"H\",\"E\",\"F\",\"A\"] },\n", - " { \"name\": \"The High Sparrow\", \"alive\": true, \"traits\": [\"H\",\"M\",\"F\",\"O\"] }\n", - "]\n", - "\n", - "FOR d IN data\n", - " INSERT d INTO Characters\n", - "\"\"\"\n", - "\n", + "insert_query = \"\"\"\r\n", + "LET data = [\r\n", + " { \"name\": \"Ned\", \"surname\": \"Stark\", \"alive\": true, \"age\": 41, \"traits\": [\"A\",\"H\",\"C\",\"N\",\"P\"] },\r\n", + " { \"name\": \"Robert\", \"surname\": \"Baratheon\", \"alive\": false, \"traits\": [\"A\",\"H\",\"C\"] },\r\n", + " { \"name\": \"Jaime\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 36, \"traits\": [\"A\",\"F\",\"B\"] },\r\n", + " { \"name\": \"Catelyn\", \"surname\": \"Stark\", \"alive\": false, \"age\": 40, \"traits\": [\"D\",\"H\",\"C\"] },\r\n", + " { \"name\": \"Cersei\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 36, \"traits\": [\"H\",\"E\",\"F\"] },\r\n", + " { \"name\": \"Daenerys\", \"surname\": \"Targaryen\", \"alive\": true, \"age\": 16, \"traits\": [\"D\",\"H\",\"C\"] },\r\n", + " { \"name\": \"Jorah\", \"surname\": \"Mormont\", \"alive\": false, \"traits\": [\"A\",\"B\",\"C\",\"F\"] },\r\n", + " { \"name\": \"Petyr\", \"surname\": \"Baelish\", \"alive\": false, \"traits\": [\"E\",\"G\",\"F\"] },\r\n", + " { \"name\": \"Viserys\", \"surname\": \"Targaryen\", \"alive\": false, \"traits\": [\"O\",\"L\",\"N\"] },\r\n", + " { \"name\": \"Jon\", \"surname\": \"Snow\", \"alive\": true, \"age\": 16, \"traits\": [\"A\",\"B\",\"C\",\"F\"] },\r\n", + " { \"name\": \"Sansa\", \"surname\": \"Stark\", \"alive\": true, \"age\": 13, \"traits\": [\"D\",\"I\",\"J\"] },\r\n", + " { \"name\": \"Arya\", \"surname\": \"Stark\", \"alive\": true, \"age\": 11, \"traits\": [\"C\",\"K\",\"L\"] },\r\n", + " { \"name\": \"Robb\", \"surname\": \"Stark\", \"alive\": false, \"traits\": [\"A\",\"B\",\"C\",\"K\"] },\r\n", + " { \"name\": \"Theon\", \"surname\": \"Greyjoy\", \"alive\": true, \"age\": 16, \"traits\": [\"E\",\"R\",\"K\"] },\r\n", + " { \"name\": \"Bran\", \"surname\": \"Stark\", \"alive\": true, \"age\": 10, \"traits\": [\"L\",\"J\"] },\r\n", + " { \"name\": \"Joffrey\", \"surname\": \"Baratheon\", \"alive\": false, \"age\": 19, \"traits\": [\"I\",\"L\",\"O\"] },\r\n", + " { \"name\": \"Sandor\", \"surname\": \"Clegane\", \"alive\": true, \"traits\": [\"A\",\"P\",\"K\",\"F\"] },\r\n", + " { \"name\": \"Tyrion\", \"surname\": \"Lannister\", \"alive\": true, \"age\": 32, \"traits\": [\"F\",\"K\",\"M\",\"N\"] },\r\n", + " { \"name\": \"Khal\", \"surname\": \"Drogo\", \"alive\": false, \"traits\": [\"A\",\"C\",\"O\",\"P\"] },\r\n", + " { \"name\": \"Tywin\", \"surname\": \"Lannister\", \"alive\": false, \"traits\": [\"O\",\"M\",\"H\",\"F\"] },\r\n", + " { \"name\": \"Davos\", \"surname\": \"Seaworth\", \"alive\": true, \"age\": 49, \"traits\": [\"C\",\"K\",\"P\",\"F\"] },\r\n", + " { \"name\": \"Samwell\", \"surname\": \"Tarly\", \"alive\": true, \"age\": 17, \"traits\": [\"C\",\"L\",\"I\"] },\r\n", + " { \"name\": \"Stannis\", \"surname\": \"Baratheon\", \"alive\": false, \"traits\": [\"H\",\"O\",\"P\",\"M\"] },\r\n", + " { \"name\": \"Melisandre\", \"alive\": true, \"traits\": [\"G\",\"E\",\"H\"] },\r\n", + " { \"name\": \"Margaery\", \"surname\": \"Tyrell\", \"alive\": false, \"traits\": [\"M\",\"D\",\"B\"] },\r\n", + " { \"name\": \"Jeor\", \"surname\": \"Mormont\", \"alive\": false, \"traits\": [\"C\",\"H\",\"M\",\"P\"] },\r\n", + " { \"name\": \"Bronn\", \"alive\": true, \"traits\": [\"K\",\"E\",\"C\"] },\r\n", + " { \"name\": \"Varys\", \"alive\": true, \"traits\": [\"M\",\"F\",\"N\",\"E\"] },\r\n", + " { \"name\": \"Shae\", \"alive\": false, \"traits\": [\"M\",\"D\",\"G\"] },\r\n", + " { \"name\": \"Talisa\", \"surname\": \"Maegyr\", \"alive\": false, \"traits\": [\"D\",\"C\",\"B\"] },\r\n", + " { \"name\": \"Gendry\", \"alive\": false, \"traits\": [\"K\",\"C\",\"A\"] },\r\n", + " { \"name\": \"Ygritte\", \"alive\": false, \"traits\": [\"A\",\"P\",\"K\"] },\r\n", + " { \"name\": \"Tormund\", \"surname\": \"Giantsbane\", \"alive\": true, \"traits\": [\"C\",\"P\",\"A\",\"I\"] },\r\n", + " { \"name\": \"Gilly\", \"alive\": true, \"traits\": [\"L\",\"J\"] },\r\n", + " { \"name\": \"Brienne\", \"surname\": \"Tarth\", \"alive\": true, \"age\": 32, \"traits\": [\"P\",\"C\",\"A\",\"K\"] },\r\n", + " { \"name\": \"Ramsay\", \"surname\": \"Bolton\", \"alive\": true, \"traits\": [\"E\",\"O\",\"G\",\"A\"] },\r\n", + " { \"name\": \"Ellaria\", \"surname\": \"Sand\", \"alive\": true, \"traits\": [\"P\",\"O\",\"A\",\"E\"] },\r\n", + " { \"name\": \"Daario\", \"surname\": \"Naharis\", \"alive\": true, \"traits\": [\"K\",\"P\",\"A\"] },\r\n", + " { \"name\": \"Missandei\", \"alive\": true, \"traits\": [\"D\",\"L\",\"C\",\"M\"] },\r\n", + " { \"name\": \"Tommen\", \"surname\": \"Baratheon\", \"alive\": true, \"traits\": [\"I\",\"L\",\"B\"] },\r\n", + " { \"name\": \"Jaqen\", \"surname\": \"H'ghar\", \"alive\": true, \"traits\": [\"H\",\"F\",\"K\"] },\r\n", + " { \"name\": \"Roose\", \"surname\": \"Bolton\", \"alive\": true, \"traits\": [\"H\",\"E\",\"F\",\"A\"] },\r\n", + " { \"name\": \"The High Sparrow\", \"alive\": true, \"traits\": [\"H\",\"M\",\"F\",\"O\"] }\r\n", + "]\r\n", + "\r\n", + "FOR d IN data\r\n", + " INSERT d INTO Characters\r\n", + "\"\"\"\r\n", + "\r\n", "db.AQLQuery(insert_query)" ], - "execution_count": 6, "outputs": [ { "output_type": "execute_result", @@ -341,29 +354,30 @@ }, "execution_count": 6 } - ] + ], + "metadata": { + "id": "QU3wB0uA5sSl", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "633d17bf-63a1-42be-abae-cf498ad0733b" + } }, { "cell_type": "markdown", + "source": [ + "As before let us check the `Characters` collection:" + ], "metadata": { "id": "ApB4UyzA5sSn", "colab_type": "text" - }, - "source": [ - "As before let us check the `Characters` collection:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "NntXNRGy5sSn", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "outputId": "843ac25c-c4ec-4998-db79-6fdd017fc88b" - }, + "execution_count": null, "source": [ "all_characters_names = \"\"\"\n", "FOR c IN Characters\n", @@ -375,10 +389,10 @@ " print(doc)\n", " print()" ], - "execution_count": 7, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Ned\n", "\n", @@ -466,43 +480,43 @@ "\n", "The High Sparrow\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "NntXNRGy5sSn", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "843ac25c-c4ec-4998-db79-6fdd017fc88b" + } }, { "cell_type": "markdown", + "source": [ + "# Filter" + ], "metadata": { "id": "9G_S0iez5sSp", "colab_type": "text" - }, - "source": [ - "# Filter" - ] + } }, { "cell_type": "markdown", - "metadata": { - "id": "bsoXpBZ95sSq", - "colab_type": "text" - }, "source": [ "To find documents that fulfill certain criteria more complex than key equality, there is the FILTER operation in AQL, which enables us to formulate arbitrary conditions for documents to match.\n", "We actually have used a filter condition before to find `Ned`:" - ] + ], + "metadata": { + "id": "bsoXpBZ95sSq", + "colab_type": "text" + } }, { "cell_type": "code", - "metadata": { - "id": "NQj_HFdS5sSq", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 51 - }, - "outputId": "9db83e64-581c-4d42-8f7f-7085862e88df" - }, + "execution_count": null, "source": [ "find_ned_query = \"\"\"\n", "FOR c IN Characters\n", @@ -514,39 +528,39 @@ " print(doc)\n", " print()" ], - "execution_count": 8, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'_key': '1026024985', '_id': 'Characters/1026024985', '_rev': '_apllrXK---', 'name': 'Ned', 'surname': 'Stark', 'alive': True, 'age': 41, 'traits': ['A', 'H', 'C', 'N', 'P']}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "NQj_HFdS5sSq", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "outputId": "9db83e64-581c-4d42-8f7f-7085862e88df" + } }, { "cell_type": "markdown", + "source": [ + "The filter condition reads like: “the attribute name of a character document must be equal to the string Ned”. If the condition applies, character document gets returned. This works with any attribute likewise:" + ], "metadata": { "id": "aF1DIQPL5sSs", "colab_type": "text" - }, - "source": [ - "The filter condition reads like: “the attribute name of a character document must be equal to the string Ned”. If the condition applies, character document gets returned. This works with any attribute likewise:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "GCXBt3bC5sSs", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 221 - }, - "outputId": "6212be2b-2e2e-407f-ccde-0d424a008fa5" - }, + "execution_count": null, "source": [ "find_ned_query = \"\"\"\n", "FOR c IN Characters\n", @@ -558,10 +572,10 @@ " print(doc)\n", " print()" ], - "execution_count": 9, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'_key': '1026024985', '_id': 'Characters/1026024985', '_rev': '_apllrXK---', 'name': 'Ned', 'surname': 'Stark', 'alive': True, 'age': 41, 'traits': ['A', 'H', 'C', 'N', 'P']}\n", "\n", @@ -575,33 +589,33 @@ "\n", "{'_key': '1026024999', '_id': 'Characters/1026024999', '_rev': '_apllrXK--N', 'name': 'Bran', 'surname': 'Stark', 'alive': True, 'age': 10, 'traits': ['L', 'J']}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "GCXBt3bC5sSs", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 221 + }, + "outputId": "6212be2b-2e2e-407f-ccde-0d424a008fa5" + } }, { "cell_type": "markdown", - "metadata": { - "id": "oUgTPRHf5sSv", - "colab_type": "text" - }, "source": [ "## Range conditions\n", "Strict equality is one possible condition we can state. There are plenty of other conditions we can formulate however. For example, we could ask for all young characters:" - ] + ], + "metadata": { + "id": "oUgTPRHf5sSv", + "colab_type": "text" + } }, { "cell_type": "code", - "metadata": { - "id": "UGPAGp395sSv", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 459 - }, - "outputId": "4b6cf176-4b85-4ec5-9144-189b8a8f4655" - }, + "execution_count": null, "source": [ "find_adults_query = \"\"\"\n", "FOR c IN Characters\n", @@ -613,10 +627,10 @@ " print(doc)\n", " print()" ], - "execution_count": 10, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Ned\n", "\n", @@ -644,32 +658,32 @@ "\n", "Brienne\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "UGPAGp395sSv", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 459 + }, + "outputId": "4b6cf176-4b85-4ec5-9144-189b8a8f4655" + } }, { "cell_type": "markdown", + "source": [ + "The operator >= stands for greater-or-equal, so every character of age 13 or older is returned (only their name in the example). We can return names and age of all characters younger than 13 by changing the operator to less-than and using the object syntax to define a subset of attributes to return:" + ], "metadata": { "id": "Vgvzhl1m5sSx", "colab_type": "text" - }, - "source": [ - "The operator >= stands for greater-or-equal, so every character of age 13 or older is returned (only their name in the example). We can return names and age of all characters younger than 13 by changing the operator to less-than and using the object syntax to define a subset of attributes to return:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "D1aKQEYk5sSx", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "outputId": "b7d39411-349e-43a8-ffe3-06670d86d0f9" - }, + "execution_count": null, "source": [ "find_young_query = \"\"\"\n", "FOR c IN Characters\n", @@ -681,10 +695,10 @@ " print(doc)\n", " print() " ], - "execution_count": 11, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'name': 'Robert', 'age': None}\n", "\n", @@ -746,32 +760,32 @@ "\n", "{'name': 'The High Sparrow', 'age': None}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "D1aKQEYk5sSx", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "b7d39411-349e-43a8-ffe3-06670d86d0f9" + } }, { "cell_type": "markdown", + "source": [ + "You may notice that it returns name and age of 30 characters, most with an age of null. The reason for this is, that null is the fallback value if an attribute is requested by the query, but no such attribute exists in the document, and the null is compares to numbers as lower (see [Type and value order](https://www.arangodb.com/docs/stable/aql/fundamentals-type-value-order.html)). Hence, it accidentally fulfills the age criterion c.age < 13 (null < 13). To not let documents pass the filter without an age attribute, we can add a second criterion:" + ], "metadata": { "id": "jKRP_2D95sSz", "colab_type": "text" - }, - "source": [ - "You may notice that it returns name and age of 30 characters, most with an age of null. The reason for this is, that null is the fallback value if an attribute is requested by the query, but no such attribute exists in the document, and the null is compares to numbers as lower (see [Type and value order](https://www.arangodb.com/docs/stable/aql/fundamentals-type-value-order.html)). Hence, it accidentally fulfills the age criterion c.age < 13 (null < 13). To not let documents pass the filter without an age attribute, we can add a second criterion:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "PtJZjoq15sS0", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 85 - }, - "outputId": "17fa4ca0-f767-4152-e009-5093c37e5ff8" - }, + "execution_count": null, "source": [ "find_young_query = \"\"\"\n", "FOR c IN Characters\n", @@ -784,41 +798,41 @@ " print(doc)\n", " print() " ], - "execution_count": 12, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'name': 'Arya', 'age': 11}\n", "\n", "{'name': 'Bran', 'age': 10}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "PtJZjoq15sS0", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 85 + }, + "outputId": "17fa4ca0-f767-4152-e009-5093c37e5ff8" + } }, { "cell_type": "markdown", + "source": [ + "This could equally be written with a boolean AND operator as:" + ], "metadata": { "id": "ulLVz1GB5sS2", "colab_type": "text" - }, - "source": [ - "This could equally be written with a boolean AND operator as:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "KHfbfMCl5sS2", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 85 - }, - "outputId": "c50317e1-894e-4da2-f949-aadb7e3e22bf" - }, + "execution_count": null, "source": [ "find_young_query = \"\"\"\n", "FOR c IN Characters\n", @@ -830,41 +844,41 @@ " print(doc)\n", " print() " ], - "execution_count": 13, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'name': 'Arya', 'age': 11}\n", "\n", "{'name': 'Bran', 'age': 10}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "KHfbfMCl5sS2", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 85 + }, + "outputId": "c50317e1-894e-4da2-f949-aadb7e3e22bf" + } }, { "cell_type": "markdown", - "metadata": { - "id": "cN6jtcV15sS4", - "colab_type": "text" - }, "source": [ "If you want documents to fulfill one or another condition, possibly for different attributes as well, use OR:" - ] + ], + "metadata": { + "id": "cN6jtcV15sS4", + "colab_type": "text" + } }, { "cell_type": "code", - "metadata": { - "id": "RI0U-atN5sS4", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 85 - }, - "outputId": "61e82ce2-8fec-48a6-c939-022943c9e83c" - }, + "execution_count": null, "source": [ "find_joffrey_query = \"\"\"\n", "FOR c IN Characters\n", @@ -876,51 +890,51 @@ " print(doc)\n", " print() " ], - "execution_count": 14, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'name': 'Jon', 'surname': 'Snow'}\n", "\n", "{'name': 'Joffrey', 'surname': 'Baratheon'}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "RI0U-atN5sS4", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 85 + }, + "outputId": "61e82ce2-8fec-48a6-c939-022943c9e83c" + } }, { "cell_type": "markdown", + "source": [ + "To learn more about Filter Operation check the [documentation](https://www.arangodb.com/docs/stable/aql/operations-filter.html)." + ], "metadata": { "id": "hf5zmA-h5sS6", "colab_type": "text" - }, - "source": [ - "To learn more about Filter Operation check the [documentation](https://www.arangodb.com/docs/stable/aql/operations-filter.html)." - ] + } }, { "cell_type": "markdown", + "source": [ + "# Sorting" + ], "metadata": { "id": "RR2VqyEp5sS6", "colab_type": "text" - }, - "source": [ - "# Sorting" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "Ggm4wxKv5sS7", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "outputId": "27f6c265-18f6-4792-b387-7b1c1aeb3985" - }, + "execution_count": null, "source": [ "all_characters_names = \"\"\"\n", "FOR c IN Characters\n", @@ -932,10 +946,10 @@ " print(doc)\n", " print()" ], - "execution_count": 15, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Ned\n", "\n", @@ -1023,32 +1037,32 @@ "\n", "The High Sparrow\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "Ggm4wxKv5sS7", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "27f6c265-18f6-4792-b387-7b1c1aeb3985" + } }, { "cell_type": "markdown", + "source": [ + "If we recall the above query, the order in which records were returned by the queries shown until is basically random. To return them in a defined order, we can add a SORT() operation." + ], "metadata": { "id": "TII5HETE5sS8", "colab_type": "text" - }, - "source": [ - "If we recall the above query, the order in which records were returned by the queries shown until is basically random. To return them in a defined order, we can add a SORT() operation." - ] + } }, { "cell_type": "code", - "metadata": { - "id": "PwCu4m5S5sS9", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "outputId": "236adf57-3109-43a2-d726-0c2fd6c3f36d" - }, + "execution_count": null, "source": [ "all_characters_names = \"\"\"\n", "FOR c IN Characters\n", @@ -1061,10 +1075,10 @@ " print(doc)\n", " print()" ], - "execution_count": 16, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Arya\n", "\n", @@ -1152,32 +1166,32 @@ "\n", "Ygritte\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "PwCu4m5S5sS9", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "236adf57-3109-43a2-d726-0c2fd6c3f36d" + } }, { "cell_type": "markdown", + "source": [ + "See how it sorted by name, then returned the ten alphabetically first coming names. We can reverse the sort order with DESC like descending:" + ], "metadata": { "id": "97x5by895sS_", "colab_type": "text" - }, - "source": [ - "See how it sorted by name, then returned the ten alphabetically first coming names. We can reverse the sort order with DESC like descending:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "x8D1Zel65sS_", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - }, - "outputId": "ab9eb7c1-97ef-4d55-bff5-0af4c18f74d9" - }, + "execution_count": null, "source": [ "all_characters_names = \"\"\"\n", "FOR c IN Characters\n", @@ -1190,10 +1204,10 @@ " print(doc)\n", " print()" ], - "execution_count": 17, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Ygritte\n", "\n", @@ -1281,44 +1295,44 @@ "\n", "Arya\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "x8D1Zel65sS_", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "outputId": "ab9eb7c1-97ef-4d55-bff5-0af4c18f74d9" + } }, { "cell_type": "markdown", + "source": [ + "The first sort was ascending, which is the default order. Because it is the default, it is not required to explicitly ask for ASC order." + ], "metadata": { "id": "Heb2C56A5sTB", "colab_type": "text" - }, - "source": [ - "The first sort was ascending, which is the default order. Because it is the default, it is not required to explicitly ask for ASC order." - ] + } }, { "cell_type": "markdown", - "metadata": { - "id": "qFMnBvEY5sTB", - "colab_type": "text" - }, "source": [ "## Sort by multiple attributes\n", "Assume we want to sort by surname. Many of the characters share a surname. The result order among characters with the same surname is undefined. We can first sort by surname, then name to determine the order:\n", "\n" - ] + ], + "metadata": { + "id": "qFMnBvEY5sTB", + "colab_type": "text" + } }, { "cell_type": "code", - "metadata": { - "id": "3tdq72pd5sTB", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 357 - }, - "outputId": "2d6bd81b-6538-43e2-99ee-0c2660e90354" - }, + "execution_count": null, "source": [ "all_characters_names = \"\"\"\n", "FOR c IN Characters\n", @@ -1336,10 +1350,10 @@ " print(doc)\n", " print()" ], - "execution_count": 18, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'surname': 'Baelish', 'name': 'Petyr'}\n", "\n", @@ -1361,53 +1375,53 @@ "\n", "{'surname': 'Giantsbane', 'name': 'Tormund'}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "3tdq72pd5sTB", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 357 + }, + "outputId": "2d6bd81b-6538-43e2-99ee-0c2660e90354" + } }, { "cell_type": "markdown", - "metadata": { - "id": "r8PIfK7I5sTC", - "colab_type": "text" - }, "source": [ "Overall, the documents are sorted by last name. If the surname is the same for two characters, the name values are compared and the result sorted.\n", "\n" - ] + ], + "metadata": { + "id": "r8PIfK7I5sTC", + "colab_type": "text" + } }, { "cell_type": "markdown", + "source": [ + "# Limiting" + ], "metadata": { "id": "D0n-Jd1l5sTD", "colab_type": "text" - }, - "source": [ - "# Limiting" - ] + } }, { "cell_type": "markdown", + "source": [ + "It may not always be necessary to return all documents, that a FOR loop would normally return. In those cases, we can limit the amount of documents with a LIMIT() operation:" + ], "metadata": { "id": "CAo_tpu55sTD", "colab_type": "text" - }, - "source": [ - "It may not always be necessary to return all documents, that a FOR loop would normally return. In those cases, we can limit the amount of documents with a LIMIT() operation:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "IStbyNUR5sTD", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 187 - }, - "outputId": "94d82e97-6dc1-4d6f-9bdc-fb7ba3396c5e" - }, + "execution_count": null, "source": [ "sample_chars_query = \"\"\"\n", "FOR c IN Characters\n", @@ -1420,10 +1434,10 @@ " print(doc)\n", " print() " ], - "execution_count": 19, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Arya\n", "\n", @@ -1435,32 +1449,32 @@ "\n", "Catelyn\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "IStbyNUR5sTD", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 187 + }, + "outputId": "94d82e97-6dc1-4d6f-9bdc-fb7ba3396c5e" + } }, { "cell_type": "markdown", + "source": [ + "LIMIT is followed by a number for the maximum document count. There is a second syntax however, which allows you to skip a certain amount of record and return the next n documents:" + ], "metadata": { "id": "XxEw2khC5sTF", "colab_type": "text" - }, - "source": [ - "LIMIT is followed by a number for the maximum document count. There is a second syntax however, which allows you to skip a certain amount of record and return the next n documents:" - ] + } }, { "cell_type": "code", - "metadata": { - "id": "nmR5SaFH5sTG", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 187 - }, - "outputId": "71c7e85f-1458-4570-f542-e55f68f2c0dc" - }, + "execution_count": null, "source": [ "sample_chars_query = \"\"\"\n", "FOR c IN Characters\n", @@ -1473,10 +1487,10 @@ " print(doc)\n", " print() " ], - "execution_count": 20, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "Brienne\n", "\n", @@ -1488,43 +1502,43 @@ "\n", "Daario\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "nmR5SaFH5sTG", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 187 + }, + "outputId": "71c7e85f-1458-4570-f542-e55f68f2c0dc" + } }, { "cell_type": "markdown", + "source": [ + "# Sort and Limit Combined" + ], "metadata": { "id": "hXX-qRhc5sTH", "colab_type": "text" - }, - "source": [ - "# Sort and Limit Combined" - ] + } }, { "cell_type": "markdown", - "metadata": { - "id": "82Chw6GN5sTH", - "colab_type": "text" - }, "source": [ "The order can also be determined by a numeric value, such as the age:\n", "A filter is applied to avoid documents without age attribute. The remaining documents are sorted by age in ascending order, and the name and age of the ten youngest characters are returned." - ] + ], + "metadata": { + "id": "82Chw6GN5sTH", + "colab_type": "text" + } }, { "cell_type": "code", - "metadata": { - "id": "YHP_xDoK5sTI", - "colab_type": "code", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 357 - }, - "outputId": "819006c6-84ce-4640-f902-e56fa464541b" - }, + "execution_count": null, "source": [ "sample_chars_query = \"\"\"\n", "FOR c IN Characters\n", @@ -1541,10 +1555,10 @@ " print(doc)\n", " print() " ], - "execution_count": 21, "outputs": [ { "output_type": "stream", + "name": "stdout", "text": [ "{'name': 'Bran', 'age': 10}\n", "\n", @@ -1566,64 +1580,72 @@ "\n", "{'name': 'Brienne', 'age': 32}\n", "\n" - ], - "name": "stdout" + ] } - ] + ], + "metadata": { + "id": "YHP_xDoK5sTI", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 357 + }, + "outputId": "819006c6-84ce-4640-f902-e56fa464541b" + } }, { "cell_type": "markdown", + "source": [ + "Please, refer to the documentation for [SORT operation](https://www.arangodb.com/docs/stable/aql/operations-sort.html) and [LIMIT operation](https://www.arangodb.com/docs/stable/aql/operations-limit.html) for more details.\n" + ], "metadata": { "id": "rVYpnTb35sTJ", "colab_type": "text" - }, - "source": [ - "Please, refer to the documentation for [SORT operation](https://www.arangodb.com/docs/stable/aql/operations-sort.html) and [LIMIT operation](https://www.arangodb.com/docs/stable/aql/operations-limit.html) for more details.\n" - ] + } }, { "cell_type": "markdown", + "source": [ + "# Next Steps" + ], "metadata": { "id": "JyX43KxG5sTJ", "colab_type": "text" - }, - "source": [ - "# Next Steps" - ] + } }, { "cell_type": "markdown", - "metadata": { - "id": "jobmCvUb5sTK", - "colab_type": "text" - }, "source": [ "To continue playing and working with ArangoDB beyond the temporary database, you can:\n", "\n", "* [Get a 2 week free Trial with the ArangoDB Cloud](https://cloud.arangodb.com/home?utm_source=AQLPart2&utm_medium=Github&utm_campaign=ArangoDB%20University)\n", "* [Download ArangoDB](https://www.arangodb.com/download-major/)\n", "* Keep Learning at thttps://www.arangodb.com/arangodb-training-center/" - ] + ], + "metadata": { + "id": "jobmCvUb5sTK", + "colab_type": "text" + } }, { "cell_type": "markdown", + "source": [ + "# Further Links" + ], "metadata": { "id": "731V5P0W5sTK", "colab_type": "text" - }, - "source": [ - "# Further Links" - ] + } }, { "cell_type": "markdown", + "source": [ + "* https://www.arangodb.com/docs/stable/aql/tutorial.html" + ], "metadata": { "id": "snWlDxcp5sTK", "colab_type": "text" - }, - "source": [ - "* https://www.arangodb.com/docs/stable/aql/tutorial.html" - ] + } } ] } \ No newline at end of file diff --git a/example_output/ArangoDBUniversity b/example_output/ArangoDBUniversity new file mode 160000 index 0000000..d114c16 --- /dev/null +++ b/example_output/ArangoDBUniversity @@ -0,0 +1 @@ +Subproject commit d114c160f5f7ada43588db0cc8d165ca8041040f