diff --git a/docusaurus-docs/docs/quick-start.md b/docusaurus-docs/docs/quick-start.md deleted file mode 100644 index 9868ba58..00000000 --- a/docusaurus-docs/docs/quick-start.md +++ /dev/null @@ -1,406 +0,0 @@ ---- -title: Quick Start ---- - -In this Dgraph quick start guide we walk through creating a graph, inserting -data, and querying the graph using [DQL](dgraph-glossary#dql). - -This guide helps you to understand how to: - -- Create a new Dgraph graph -- Connect your graph to the Ratel web client -- Add data using mutations -- Query the graph using DQL -- Update the graph schema to support more advanced queries - -## Run Dgraph and connect the Ratel web UI - -The recommended way to get started with Dgraph for local development is by using -the official Dgraph Docker image. - -In this section we'll create a new graph, then we'll connect our new graph to -[Ratel](dgraph-glossary#ratel), the web-based UI for Dgraph. - -### Run Dgraph with Docker - -The [`dgraph/standalone`](https://hub.docker.com/r/dgraph/standalone) Docker image has everything needed to run Dgraph locally. - -Ensure you have [Docker installed](https://www.docker.com/), then run the following command to start a local Dgraph instance: - -```bash -docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:latest -``` - -This will create a local Dgraph instance and expose the ports necessary to connect to Dgraph via HTTP and gRPC. Specifically: - -* `docker run` - initiates a new Docker container -* `--rm` - automatically removes the container when it exits, helping with cleanup -* `-it` - uses interactive mode to show output of the container -* `-p 8080:8080` - maps port 8080 from the host machine to port 8080 in the Docker container to allow Dgraph HTTP connections -* `-p 9080:9080` - maps port 9080 from the host machine to port 9080 in the Docker container to allow Dgraph gRPC connections -* `dgraph/standalone:latest` - specifies the Docker image to use, this is the official Dgraph image with latest tag - -### Connect Ratel - -Ratel is a web-based UI dashboard for interacting with Dgraph using Dgraph's query language, [DQL](dgraph-glossary#dql) - -Run Ratel locally by running the `dgraph/ratel` container with the following command: - -```bash -docker run --rm -it -p 8000:8000 dgraph/ratel:latest -``` - -This will start Ratel. Open your web browser and navigate to `http://localhost:8000`, then enter `http://localhost:8080` for the "Dgraph Conn String". This will allow Ratel to connect to our local Dgraph instance and execute DQL queries. - -![Setting up Ratel](/images/dgraph/quickstart/ratel-docker-connection.png) - -Now select **Connect** to verify the connection and then select **Continue** to access the Ratel console. - -![Setting up Ratel local connection](/images/dgraph/quickstart/ratel-docker-overview.png) - -Now we're ready to add data to our graph. - -## Add data to the graph with a mutation - -Graph databases like Dgraph use a data model called the **property graph**, -which consists of [**nodes**](dgraph-glossary#node), -[**relationships**](dgraph-glossary#relationship) that connect nodes, and key-value -pair **properties** that describe nodes and relationships. - -With Dgraph, we use **triples** to describe each piece of our graph, which when -combined together make up our property graph. Triples are composed of a subject, -predicate, and object. - -```text - . -``` - -The subject always refers to a [node](dgraph-glossary#node), -[predicates](dgraph-glossary#predicate) can be a relationship or property, and the -object can be a node or property value. You can read more about triples in the -[RDF section of the docs](/dql/dql-rdf), but for now let's move on to -creating data in Dgraph using triples. - -Let's create data about movies, characters, and their genres. Here's the -property graph representation of the data we'll create: - -![Movie and actor data model](/images/dgraph/quickstart/data-model.png) - -### Add mutation in Ratel - -The create, update, and delete operations in Dgraph are called mutations. - -In the Ratel **Console** page, select the **Mutate** tab, then paste the -following mutation: - -```dql -{ - set { - - _:scifi "Genre" . - _:scifi "Sci-Fi" . - - _:starwars "Movie" . - _:starwars "Star Wars: Episode IV - A New Hope" . - _:starwars "1977-05-25"^^ . - - - _:startrek "Movie" . - _:startrek "Star Trek: The Motion Picture" . - _:startrek "1979-12-07"^^ . - - _:george "Person" . - _:george "George Lucas" . - - _:luke "Character" . - _:luke "Luke Skywalker" . - - _:leia "Character" . - _:leia "Princess Leia" . - - _:han "Character" . - _:han "Han Solo" . - - _:starwars _:scifi . - _:startrek _:scifi . - - _:starwars _:george . - - _:starwars _:luke . - _:starwars _:leia . - _:starwars _:han . - - } -} -``` - -The preceding DQL mutation uses -[N-Quad RDF format](/dql/dql-rdf#n-quads-format) to define the triples that -make up the property graph we want to create. - -### View mutation results - -Select **Run** to execute the mutation. In the JSON tab we can see the result of -this mutation. - -```json - { - "data": { - "code": "Success", - "message": "Done", - "queries": null, - "uids": { - "george": "0x4", - "han": "0x7", - "leia": "0x6", - "luke": "0x5", - "scifi": "0x1", - "startrek": "0x3", - "starwars": "0x2" - } - } - } -``` - -Dgraph displays the universal identifiers ([UID](dgraph-glossary#uid)) of the -nodes that were created. - -## Query the graph - -### Query for all movies - -In the **Console** page, select the **Query** tab and run this query: - -```dql - { - movies(func: type(Movie)) { - Movie.title - Movie.genre { - Genre.name - } - Movie.director { - Person.name - } - Movie.character { - Character.name - } - } - } -``` - -This query searches for all `Movie` nodes as the start of the traversal using -the `type(Movie)` function to define the starting point of our query traversal, -then finds any genres, directors, and characters connected to each movie. - -### View results in JSON and graph visualization - -In Ratel's JSON tab we can view the results of this query as JSON: - -```json - { - "data": { - "movies": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope", - "Movie.genre": [ - { - "Genre.name": "Sci-Fi" - } - ], - "Movie.director": [ - { - "Person.name": "George Lucas" - } - ], - "Movie.character": [ - { - "Character.name": "Luke Skywalker" - }, - { - "Character.name": "Princess Leia" - }, - { - "Character.name": "Han Solo" - } - ] - }, - { - "Movie.title": "Star Trek: The Motion Picture", - "Movie.genre": [ - { - "Genre.name": "Sci-Fi" - } - ] - } - ] - } - } -``` - -In the response panel, Select **Graph** to view a graph visualization of the -results of our query: - -![Query result graph visualization](/images/dgraph/quickstart/query-result-1.png) - -## Update the graph schema and query using an index - -The previous query used the `type()` function to find the starting point of our -graph traversal. We can use more complex functions to filter by string -comparison operator, and others, however to use these functions we must first -update the graph schema to create an index on the predicates we want to use in -these functions. - -The [function documentation](/dql/query/functions) specifies which kind of -index is needed for each function. - -We'll use Ratel to alter the schema to add indexes on some of the data so -queries can use term matching, filtering, and sorting. - -### Create an index for movie title - -In Ratel's **Schema** page, select **Predicates**. Here we can see all the -predicates used in the graph. A [predicate](dgraph-glossary#predicate) is -Dgraph's internal representation of a node, property, or relationship. - -Select the `Movie.title` predicate. Ratel displays details about the predicate -type and indexes. - -Change the type to **string** then select **index** and select **term** for the -`Movie.title` predicate, then select **Update** to apply the index. - -![Adding an index for movie title](/images/dgraph/quickstart/schema-title.png) - -### Create an index for movie release date - -Next, we'll create an index for the `Movie.release_date` predicate. - -Select the `Movie.release_date` predicate. Change the type to **dateTime**. -Select **index** and choose **year** for the index tokenizer. Click **Update** -to apply the index on the `release-date` predicate. - -![Adding an index for movie release date](/images/dgraph/quickstart/schema-date.png) - -### Query using indexes - -Now let's find all movies with the term "Star" in their title and released -before 1979. - -In the **Console** page select the **Query** tab and run this query: - -```dql - { - movieSearch(func: allofterms(Movie.title, "Star"), orderasc: Movie.release_date) @filter(lt(Movie.release_date, "1979")) { - Movie.title - Movie.release_date - Movie.director { - Person.name - } - Movie.character (orderasc: Character.name) { - Character.name - } - } - } -``` - -We can see the JSON result in the JSON tab: - -```json - { - "data": { - "movieSearch": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope", - "Movie.release_date": "1977-05-25T00:00:00Z", - "Movie.director": [ - { - "Person.name": "George Lucas" - } - ], - "Movie.character": [ - { - "Character.name": "Han Solo" - }, - { - "Character.name": "Luke Skywalker" - }, - { - "Character.name": "Princess Leia" - } - ] - } - ] - } - } -``` - -And also view the graph visualization of the result in the Graph tab: - -![Graph visualization of query result](/images/dgraph/quickstart/query-result-2.png) - -Try changing the release date and the search terms conditions to see Dgraph -search and filtering in action. - -## Reverse relationship query - -### Add reverse relationship - -In the previous queries we traversed from the movie node to its connected genre -node, but what if we want to find all movies connected to a genre node? In order -to traverse from a genre node to a movie node we need to explicitly define the -`Movie.genre` predicate as a reverse relationship. - -To define a reverse relationship for the `Movie.genre` predicate we'll return to -the Schema page in Ratel, select the `Movie.genre` predicate and toggle the -**reverse** checkbox. Then select **Update** to apply this schema change. - -![Define a reverse relationship in the graph schema](/images/dgraph/quickstart/schema-reverse.png) - -### Query using the reverse relationship - -In a DQL query the `~` operator is used to specify a reverse relationship. To -traverse from a genre node to a movie node we use the syntax `~Movie.genre`. - -In this query we find all movies connected to the "Sci-Fi" genre: - -```dql - { - genreSearch(func: type(Genre)) { - Genre.name - movies: ~Movie.genre { - Movie.title - } - } - } -``` - -Note that we can also alias the field name to "movies" in our result JSON using -the syntax `movies: ~Movie.genre`. - -```json - { - "data": { - "genreSearch": [ - { - "Genre.name": "Sci-Fi", - "movies": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope" - }, - { - "Movie.title": "Star Trek: The Motion Picture" - } - ] - } - ] - } - } -``` - -In this quick start we created a new graph instance using Dgraph, added data, -queried the graph, visualized the results, and updated the schema of our graph. - -## Where to go from here - -- Learn more about using [DQL](/dql/query/dql-query) to query your graph. -- Go to [Clients](clients) to see how to communicate with Dgraph - from your app. diff --git a/docusaurus-docs/docs/quick-start.mdx b/docusaurus-docs/docs/quick-start.mdx new file mode 100644 index 00000000..50a60796 --- /dev/null +++ b/docusaurus-docs/docs/quick-start.mdx @@ -0,0 +1,137 @@ +--- +title: Quick Start +--- +import QueryTab from '/images/quickstart-querytab.png'; + + + +Welcome to Dgraph! This guide will get you up and running in minutes. You'll learn how to start Dgraph, load sample data, and run your first queries. + +## Prerequisites + +- [Docker](https://www.docker.com/) installed and running +- A terminal window +- About 5 minutes + +## Step 1: Start Dgraph + +Run Dgraph using the official Docker image: + +```bash +docker run --detach --name dgraph-play \ + -v $(pwd):/dgraph \ + -p "8080:8080" \ + -p "9080:9080" \ + dgraph/standalone:v24.1.4 +``` + +This command: +- Starts Dgraph in the background (`--detach`) +- Names the container `dgraph-play` for easy management +- Mounts your current directory to `/dgraph` in the container +- Exposes ports 8080 (HTTP) and 9080 (gRPC) + +**Verify it's running:** + +```bash +curl http://localhost:8080/health | jq +``` + +You should see a healthy status response. If you don't have `jq` installed, you can remove it from the command. + + + +## Step 2: Load Sample Data + +Download the sample dataset (movie data): + +```bash +wget https://github.com/dgraph-io/dgraph-benchmarks/raw/refs/heads/main/data/1million.rdf.gz +wget https://raw.githubusercontent.com/dgraph-io/dgraph-benchmarks/refs/heads/main/data/21million.schema +``` + +Load the data into Dgraph: + +```bash +docker exec -it dgraph-play dgraph live \ + -f 1million.rdf.gz \ + -s 21million.schema +``` + +This loads over 1 million movie-related facts into your database. The process takes about 15-30 seconds. + + + +## Step 3: Open Ratel UI + +[Ratel](dgraph-glossary#ratel) is Dgraph's visual query interface. Start it with: + +```bash +docker run --rm -it -p 8000:8000 dgraph/ratel:latest +``` + +Then: +1. Open `http://localhost:8000` in your browser +2. Enter `http://localhost:8080` as the Dgraph connection string +3. Click **Connect** + + + +You're now connected! Click **Continue** to access the console. + + +## Step 4: Run Your First Query + +In Ratel's **Query** tab, paste this [DQL](dgraph-glossary#dql) query: + +```dql +{ + film(func: has(genre), first: 3) { + name@* + genre { + name: name@. + } + starring { + performance.actor { + name: name@. + } + performance.character { + name: name@. + } + } + } +} +``` + +Ratel Console + +Click **Run** to execute the query. This finds movies with genres and displays their details, including actors and characters. + +**What this query does:** +- Finds nodes that have a `genre` predicate +- Returns the first 3 results +- Retrieves movie names, genres, and starring information + +## Step 5: Explore the Results + +View your results in two ways: + +1. **JSON tab** - See the raw data structure +2. **Graph tab** - Visualize the relationships + +Switch to the **Graph** tab to see how movies, genres, actors, and characters are connected. + +![image](/images/quickstart-dql-ratel.png) + +## What's Next? + +Congratulations! You've successfully: +- ✅ Started a Dgraph instance +- ✅ Loaded real-world data +- ✅ Run your first graph query +- ✅ Explored results visually + +**Continue learning:** +- [DQL Query Guide](/dql/query/dql-query) - Master Dgraph's query language +- [Clients](/clients) - Connect from your application +- [Installation Guide](/installation/download) - Production deployment options diff --git a/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.md b/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.md deleted file mode 100644 index 9868ba58..00000000 --- a/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.md +++ /dev/null @@ -1,406 +0,0 @@ ---- -title: Quick Start ---- - -In this Dgraph quick start guide we walk through creating a graph, inserting -data, and querying the graph using [DQL](dgraph-glossary#dql). - -This guide helps you to understand how to: - -- Create a new Dgraph graph -- Connect your graph to the Ratel web client -- Add data using mutations -- Query the graph using DQL -- Update the graph schema to support more advanced queries - -## Run Dgraph and connect the Ratel web UI - -The recommended way to get started with Dgraph for local development is by using -the official Dgraph Docker image. - -In this section we'll create a new graph, then we'll connect our new graph to -[Ratel](dgraph-glossary#ratel), the web-based UI for Dgraph. - -### Run Dgraph with Docker - -The [`dgraph/standalone`](https://hub.docker.com/r/dgraph/standalone) Docker image has everything needed to run Dgraph locally. - -Ensure you have [Docker installed](https://www.docker.com/), then run the following command to start a local Dgraph instance: - -```bash -docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:latest -``` - -This will create a local Dgraph instance and expose the ports necessary to connect to Dgraph via HTTP and gRPC. Specifically: - -* `docker run` - initiates a new Docker container -* `--rm` - automatically removes the container when it exits, helping with cleanup -* `-it` - uses interactive mode to show output of the container -* `-p 8080:8080` - maps port 8080 from the host machine to port 8080 in the Docker container to allow Dgraph HTTP connections -* `-p 9080:9080` - maps port 9080 from the host machine to port 9080 in the Docker container to allow Dgraph gRPC connections -* `dgraph/standalone:latest` - specifies the Docker image to use, this is the official Dgraph image with latest tag - -### Connect Ratel - -Ratel is a web-based UI dashboard for interacting with Dgraph using Dgraph's query language, [DQL](dgraph-glossary#dql) - -Run Ratel locally by running the `dgraph/ratel` container with the following command: - -```bash -docker run --rm -it -p 8000:8000 dgraph/ratel:latest -``` - -This will start Ratel. Open your web browser and navigate to `http://localhost:8000`, then enter `http://localhost:8080` for the "Dgraph Conn String". This will allow Ratel to connect to our local Dgraph instance and execute DQL queries. - -![Setting up Ratel](/images/dgraph/quickstart/ratel-docker-connection.png) - -Now select **Connect** to verify the connection and then select **Continue** to access the Ratel console. - -![Setting up Ratel local connection](/images/dgraph/quickstart/ratel-docker-overview.png) - -Now we're ready to add data to our graph. - -## Add data to the graph with a mutation - -Graph databases like Dgraph use a data model called the **property graph**, -which consists of [**nodes**](dgraph-glossary#node), -[**relationships**](dgraph-glossary#relationship) that connect nodes, and key-value -pair **properties** that describe nodes and relationships. - -With Dgraph, we use **triples** to describe each piece of our graph, which when -combined together make up our property graph. Triples are composed of a subject, -predicate, and object. - -```text - . -``` - -The subject always refers to a [node](dgraph-glossary#node), -[predicates](dgraph-glossary#predicate) can be a relationship or property, and the -object can be a node or property value. You can read more about triples in the -[RDF section of the docs](/dql/dql-rdf), but for now let's move on to -creating data in Dgraph using triples. - -Let's create data about movies, characters, and their genres. Here's the -property graph representation of the data we'll create: - -![Movie and actor data model](/images/dgraph/quickstart/data-model.png) - -### Add mutation in Ratel - -The create, update, and delete operations in Dgraph are called mutations. - -In the Ratel **Console** page, select the **Mutate** tab, then paste the -following mutation: - -```dql -{ - set { - - _:scifi "Genre" . - _:scifi "Sci-Fi" . - - _:starwars "Movie" . - _:starwars "Star Wars: Episode IV - A New Hope" . - _:starwars "1977-05-25"^^ . - - - _:startrek "Movie" . - _:startrek "Star Trek: The Motion Picture" . - _:startrek "1979-12-07"^^ . - - _:george "Person" . - _:george "George Lucas" . - - _:luke "Character" . - _:luke "Luke Skywalker" . - - _:leia "Character" . - _:leia "Princess Leia" . - - _:han "Character" . - _:han "Han Solo" . - - _:starwars _:scifi . - _:startrek _:scifi . - - _:starwars _:george . - - _:starwars _:luke . - _:starwars _:leia . - _:starwars _:han . - - } -} -``` - -The preceding DQL mutation uses -[N-Quad RDF format](/dql/dql-rdf#n-quads-format) to define the triples that -make up the property graph we want to create. - -### View mutation results - -Select **Run** to execute the mutation. In the JSON tab we can see the result of -this mutation. - -```json - { - "data": { - "code": "Success", - "message": "Done", - "queries": null, - "uids": { - "george": "0x4", - "han": "0x7", - "leia": "0x6", - "luke": "0x5", - "scifi": "0x1", - "startrek": "0x3", - "starwars": "0x2" - } - } - } -``` - -Dgraph displays the universal identifiers ([UID](dgraph-glossary#uid)) of the -nodes that were created. - -## Query the graph - -### Query for all movies - -In the **Console** page, select the **Query** tab and run this query: - -```dql - { - movies(func: type(Movie)) { - Movie.title - Movie.genre { - Genre.name - } - Movie.director { - Person.name - } - Movie.character { - Character.name - } - } - } -``` - -This query searches for all `Movie` nodes as the start of the traversal using -the `type(Movie)` function to define the starting point of our query traversal, -then finds any genres, directors, and characters connected to each movie. - -### View results in JSON and graph visualization - -In Ratel's JSON tab we can view the results of this query as JSON: - -```json - { - "data": { - "movies": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope", - "Movie.genre": [ - { - "Genre.name": "Sci-Fi" - } - ], - "Movie.director": [ - { - "Person.name": "George Lucas" - } - ], - "Movie.character": [ - { - "Character.name": "Luke Skywalker" - }, - { - "Character.name": "Princess Leia" - }, - { - "Character.name": "Han Solo" - } - ] - }, - { - "Movie.title": "Star Trek: The Motion Picture", - "Movie.genre": [ - { - "Genre.name": "Sci-Fi" - } - ] - } - ] - } - } -``` - -In the response panel, Select **Graph** to view a graph visualization of the -results of our query: - -![Query result graph visualization](/images/dgraph/quickstart/query-result-1.png) - -## Update the graph schema and query using an index - -The previous query used the `type()` function to find the starting point of our -graph traversal. We can use more complex functions to filter by string -comparison operator, and others, however to use these functions we must first -update the graph schema to create an index on the predicates we want to use in -these functions. - -The [function documentation](/dql/query/functions) specifies which kind of -index is needed for each function. - -We'll use Ratel to alter the schema to add indexes on some of the data so -queries can use term matching, filtering, and sorting. - -### Create an index for movie title - -In Ratel's **Schema** page, select **Predicates**. Here we can see all the -predicates used in the graph. A [predicate](dgraph-glossary#predicate) is -Dgraph's internal representation of a node, property, or relationship. - -Select the `Movie.title` predicate. Ratel displays details about the predicate -type and indexes. - -Change the type to **string** then select **index** and select **term** for the -`Movie.title` predicate, then select **Update** to apply the index. - -![Adding an index for movie title](/images/dgraph/quickstart/schema-title.png) - -### Create an index for movie release date - -Next, we'll create an index for the `Movie.release_date` predicate. - -Select the `Movie.release_date` predicate. Change the type to **dateTime**. -Select **index** and choose **year** for the index tokenizer. Click **Update** -to apply the index on the `release-date` predicate. - -![Adding an index for movie release date](/images/dgraph/quickstart/schema-date.png) - -### Query using indexes - -Now let's find all movies with the term "Star" in their title and released -before 1979. - -In the **Console** page select the **Query** tab and run this query: - -```dql - { - movieSearch(func: allofterms(Movie.title, "Star"), orderasc: Movie.release_date) @filter(lt(Movie.release_date, "1979")) { - Movie.title - Movie.release_date - Movie.director { - Person.name - } - Movie.character (orderasc: Character.name) { - Character.name - } - } - } -``` - -We can see the JSON result in the JSON tab: - -```json - { - "data": { - "movieSearch": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope", - "Movie.release_date": "1977-05-25T00:00:00Z", - "Movie.director": [ - { - "Person.name": "George Lucas" - } - ], - "Movie.character": [ - { - "Character.name": "Han Solo" - }, - { - "Character.name": "Luke Skywalker" - }, - { - "Character.name": "Princess Leia" - } - ] - } - ] - } - } -``` - -And also view the graph visualization of the result in the Graph tab: - -![Graph visualization of query result](/images/dgraph/quickstart/query-result-2.png) - -Try changing the release date and the search terms conditions to see Dgraph -search and filtering in action. - -## Reverse relationship query - -### Add reverse relationship - -In the previous queries we traversed from the movie node to its connected genre -node, but what if we want to find all movies connected to a genre node? In order -to traverse from a genre node to a movie node we need to explicitly define the -`Movie.genre` predicate as a reverse relationship. - -To define a reverse relationship for the `Movie.genre` predicate we'll return to -the Schema page in Ratel, select the `Movie.genre` predicate and toggle the -**reverse** checkbox. Then select **Update** to apply this schema change. - -![Define a reverse relationship in the graph schema](/images/dgraph/quickstart/schema-reverse.png) - -### Query using the reverse relationship - -In a DQL query the `~` operator is used to specify a reverse relationship. To -traverse from a genre node to a movie node we use the syntax `~Movie.genre`. - -In this query we find all movies connected to the "Sci-Fi" genre: - -```dql - { - genreSearch(func: type(Genre)) { - Genre.name - movies: ~Movie.genre { - Movie.title - } - } - } -``` - -Note that we can also alias the field name to "movies" in our result JSON using -the syntax `movies: ~Movie.genre`. - -```json - { - "data": { - "genreSearch": [ - { - "Genre.name": "Sci-Fi", - "movies": [ - { - "Movie.title": "Star Wars: Episode IV - A New Hope" - }, - { - "Movie.title": "Star Trek: The Motion Picture" - } - ] - } - ] - } - } -``` - -In this quick start we created a new graph instance using Dgraph, added data, -queried the graph, visualized the results, and updated the schema of our graph. - -## Where to go from here - -- Learn more about using [DQL](/dql/query/dql-query) to query your graph. -- Go to [Clients](clients) to see how to communicate with Dgraph - from your app. diff --git a/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.mdx b/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.mdx new file mode 100644 index 00000000..50a60796 --- /dev/null +++ b/docusaurus-docs/docs_versioned_docs/version-v24.1/quick-start.mdx @@ -0,0 +1,137 @@ +--- +title: Quick Start +--- +import QueryTab from '/images/quickstart-querytab.png'; + + + +Welcome to Dgraph! This guide will get you up and running in minutes. You'll learn how to start Dgraph, load sample data, and run your first queries. + +## Prerequisites + +- [Docker](https://www.docker.com/) installed and running +- A terminal window +- About 5 minutes + +## Step 1: Start Dgraph + +Run Dgraph using the official Docker image: + +```bash +docker run --detach --name dgraph-play \ + -v $(pwd):/dgraph \ + -p "8080:8080" \ + -p "9080:9080" \ + dgraph/standalone:v24.1.4 +``` + +This command: +- Starts Dgraph in the background (`--detach`) +- Names the container `dgraph-play` for easy management +- Mounts your current directory to `/dgraph` in the container +- Exposes ports 8080 (HTTP) and 9080 (gRPC) + +**Verify it's running:** + +```bash +curl http://localhost:8080/health | jq +``` + +You should see a healthy status response. If you don't have `jq` installed, you can remove it from the command. + + + +## Step 2: Load Sample Data + +Download the sample dataset (movie data): + +```bash +wget https://github.com/dgraph-io/dgraph-benchmarks/raw/refs/heads/main/data/1million.rdf.gz +wget https://raw.githubusercontent.com/dgraph-io/dgraph-benchmarks/refs/heads/main/data/21million.schema +``` + +Load the data into Dgraph: + +```bash +docker exec -it dgraph-play dgraph live \ + -f 1million.rdf.gz \ + -s 21million.schema +``` + +This loads over 1 million movie-related facts into your database. The process takes about 15-30 seconds. + + + +## Step 3: Open Ratel UI + +[Ratel](dgraph-glossary#ratel) is Dgraph's visual query interface. Start it with: + +```bash +docker run --rm -it -p 8000:8000 dgraph/ratel:latest +``` + +Then: +1. Open `http://localhost:8000` in your browser +2. Enter `http://localhost:8080` as the Dgraph connection string +3. Click **Connect** + + + +You're now connected! Click **Continue** to access the console. + + +## Step 4: Run Your First Query + +In Ratel's **Query** tab, paste this [DQL](dgraph-glossary#dql) query: + +```dql +{ + film(func: has(genre), first: 3) { + name@* + genre { + name: name@. + } + starring { + performance.actor { + name: name@. + } + performance.character { + name: name@. + } + } + } +} +``` + +Ratel Console + +Click **Run** to execute the query. This finds movies with genres and displays their details, including actors and characters. + +**What this query does:** +- Finds nodes that have a `genre` predicate +- Returns the first 3 results +- Retrieves movie names, genres, and starring information + +## Step 5: Explore the Results + +View your results in two ways: + +1. **JSON tab** - See the raw data structure +2. **Graph tab** - Visualize the relationships + +Switch to the **Graph** tab to see how movies, genres, actors, and characters are connected. + +![image](/images/quickstart-dql-ratel.png) + +## What's Next? + +Congratulations! You've successfully: +- ✅ Started a Dgraph instance +- ✅ Loaded real-world data +- ✅ Run your first graph query +- ✅ Explored results visually + +**Continue learning:** +- [DQL Query Guide](/dql/query/dql-query) - Master Dgraph's query language +- [Clients](/clients) - Connect from your application +- [Installation Guide](/installation/download) - Production deployment options diff --git a/docusaurus-docs/static/images/quickstart-dql-ratel.png b/docusaurus-docs/static/images/quickstart-dql-ratel.png new file mode 100644 index 00000000..0e90debe Binary files /dev/null and b/docusaurus-docs/static/images/quickstart-dql-ratel.png differ diff --git a/docusaurus-docs/static/images/quickstart-querytab.png b/docusaurus-docs/static/images/quickstart-querytab.png new file mode 100644 index 00000000..fb42d01d Binary files /dev/null and b/docusaurus-docs/static/images/quickstart-querytab.png differ