Skip to content

Commit

Permalink
Add docs for CLI and WHERE clause (#322)
Browse files Browse the repository at this point in the history
* Fix #312

* Fix #311
  • Loading branch information
prrao87 authored Dec 20, 2024
1 parent 3184d07 commit 3996955
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 15 deletions.
19 changes: 16 additions & 3 deletions src/content/docs/client-apis/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ Opened the database under in-memory mode.
Enter ":help" for usage hints.
kuzu>
```

## Shell commands

Once you start the shell, you can issue Cypher queries as shown in the [get started](/get-started)
section. List all available shell commands by running `./kuzu -h`.

```bash
$ ./kuzu -h
./kuzu [databasePath] {OPTIONS}
$ kuzu -h
kuzu [databasePath] {OPTIONS}

KuzuDB Shell

Expand All @@ -69,6 +68,20 @@ $ ./kuzu -h
arguments to be treated as positional options
```

:::caution[Note on memory usage]
By default, Kùzu's CLI is launched with a maximum buffer pool size of 80% of the available memory.
If you want to launch the Kùzu CLI with a different buffer pool size, you can do so by setting the
`--defaultbpsize` or `-d` flag to the desired value in megabytes.
:::


To limit the buffer pool size to use just 4GB of memory, you can use the following command:

```bash
kuzu --defaultbpsize 4096
```


#### `:help`
Show built-in command list within the Kùzu shell.

Expand Down
48 changes: 36 additions & 12 deletions src/content/docs/cypher/query-clauses/where.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ RETURN *;
```
Output:
```
---------------------------------------------
| a |
---------------------------------------------
| (label:User, 0:1, {name:Karissa, age:40}) |
---------------------------------------------
| (label:User, 0:2, {name:Zhang, age:50}) |
---------------------------------------------
┌──────────────────────────────────────────────────┐
a
│ NODE │
├──────────────────────────────────────────────────┤
│ {_ID: 0:1, _LABEL: User, name: Karissa, age: 40} │
│ {_ID: 0:2, _LABEL: User, name: Zhang, age: 50}
└──────────────────────────────────────────────────┘
```

The boolean predicate specified above can be understood as it reads: Users "a" whose ages are
Expand All @@ -44,9 +44,33 @@ RETURN *;
```
Output:
```
---------------------------------------------
| a |
---------------------------------------------
| (label:User, 0:1, {name:Karissa, age:40}) |
---------------------------------------------
┌──────────────────────────────────────────────────┐
│ a │
│ NODE │
├──────────────────────────────────────────────────┤
│ {_ID: 0:1, _LABEL: User, name: Karissa, age: 40} │
└──────────────────────────────────────────────────┘
```

## `WHERE` subquery on a relationship

You can also specify a subquery that matches a relationship using the `WHERE` clause.

```cypher
MATCH (a:User)
WHERE (a)-[r1:Follows]->(b:User {name: "Noura"})-[r2:LivesIn]->(c:City {name: "Guelph"})
RETURN a;
```
```
┌────────────────────────────────────────────────┐
│ a │
│ NODE │
├────────────────────────────────────────────────┤
│ {_ID: 0:2, _LABEL: User, name: Zhang, age: 50} │
└────────────────────────────────────────────────┘
```

The above query matches users who follow "Noura" and lives in "Guelph". Note that you can only
`RETURN` the nodes that are in the scope of the `MATCH` clause (the nodes and relationships that
are in the `WHERE` clause are not returned).

0 comments on commit 3996955

Please sign in to comment.