Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

AQL syntax highlighter #1032

Merged
merged 9 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 3.10/administration-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ requested _shard_ (_numberOfShards_) within the Cluster.

Example:

```
```js
127.0.0.1:8530@_system> db._create("test", {"replicationFactor": 3})
```

Expand Down Expand Up @@ -100,20 +100,20 @@ key attributes are present in the documents you send, or in case of AQL, that
you use a document reference or an object for the UPDATE, REPLACE or REMOVE
operation which includes the shard key attributes:

```js
```aql
FOR doc IN sharded_collection
FILTER doc._key == "123"
UPDATE doc WITH { … } IN sharded_collection
```

```js
```aql
UPDATE { _key: "123", country: "…" } WITH { … } IN sharded_collection
```

Using a string with just the document key as key expression instead will be
processed without shard hints and thus perform slower:

```js
```aql
UPDATE "123" WITH { … } IN sharded_collection
```

Expand Down Expand Up @@ -277,13 +277,13 @@ do {
This script has to be executed in the [`arangosh`](programs-arangosh.html)
by issuing the following command:

```
```bash
arangosh --server.username <username> --server.password <password> --javascript.execute <path/to/serverCleanMonitor.js> -- DBServer<number>
```

The output should be similar to the one below:

```
```bash
arangosh --server.username root --server.password pass --javascript.execute ~./serverCleanMonitor.js -- DBServer0002
[7836] INFO Checking shard distribution every 10 seconds...
[7836] INFO Shards to be moved away from node DBServer0002: 9
Expand Down
2 changes: 1 addition & 1 deletion 3.10/administration-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ authentication = true
So you see, a command line option `‑‑section.param value` can be easily
translated to an option in a configuration file:

```js
```conf
[section]
param = value
```
Expand Down
4 changes: 2 additions & 2 deletions 3.10/administration-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ At any point you may check the current state of your license in _arangosh_:
127.0.0.1:8529@_system> db._getLicense();
```

```js
```json
{
"features": {
"expires": 1632411828
},
"license": "JD4E ... dnDw==",
"version": 1,
"status": "good"
"hash" : "...."
"hash" : "..."
}
```

Expand Down
10 changes: 5 additions & 5 deletions 3.10/administration-managing-users-in-arangosh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This is again for backward compatibility.

Fire up *arangosh* and require the users module. Use it to create a new user:

```
```js
arangosh --server.endpoint tcp://127.0.0.1:8529 ...
...
> const users = require('@arangodb/users');
Expand All @@ -37,7 +37,7 @@ Note that running the command like this may store the password literally in
ArangoShell's history. To avoid that, either disable the history
(`--console.history false`) or use a dynamically created password, e.g.:

```
```js
> passwd = require('internal').genRandomAlphaNumbers(20);
> users.save('JohnSmith', passwd);
```
Expand All @@ -49,15 +49,15 @@ While there, you probably want to change the password of the default `root`
user too. Otherwise one will be able to connect with the default `root` user
and its empty password. The following commands change the `root` user's password:

```
```js
> passwd = require('internal').genRandomAlphaNumbers(20);
> require('@arangodb/users').update('root', passwd);
```

Back to our user account *JohnSmith*. Let us create a new database
and grant him access to it with `grantDatabase()`:

```
```js
> db._createDatabase('testdb');
> users.grantDatabase('JohnSmith', 'testdb', 'rw');
```
Expand All @@ -79,7 +79,7 @@ Before we can grant *JohnSmith* access to a collection, we first have to
connect to the new database and create a collection. Disconnect `arangosh`
by pressing Ctrl+C twice. Then reconnect, but to the database we created:

```
```js
arangosh --server.endpoint tcp://127.0.0.1:8529 --server.database testdb ...
...
> db._create('testcoll');
Expand Down
20 changes: 11 additions & 9 deletions 3.10/analyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ attributes:
removing tokens that contain non-printable characters. To encode UTF-8
strings to hex strings you can use e.g.
- AQL:
```js
```aql
FOR token IN ["and","the"] RETURN TO_HEX(token)
```
- arangosh / Node.js:
Expand Down Expand Up @@ -1005,16 +1005,17 @@ The *properties* allowed for this Analyzer are an object with the following attr

**Examples**

Create and use a `classification` Analyzer with a stored "cooking" classifier to classify items.
Create and use a `classification` Analyzer with a stored "cooking" classifier
to classify items.

```js
var analyzers = require("@arangodb/analyzers");
var classifier_single = analyzers.save("classifier_single", "classification", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin" }, ["frequency", "norm", "position"]);
var classifier_top_two = analyzers.save("classifier_double", "classification", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin", "top_k": 2 }, ["frequency", "norm", "position"]);
db._query(`LET str = 'Which baking dish is best to bake a banana bread ?'
db._query(`LET str = "Which baking dish is best to bake a banana bread ?"
RETURN {
"all": TOKENS(str, 'classifier_single'),
"double": TOKENS(str, 'classifier_double')
"all": TOKENS(str, "classifier_single"),
"double": TOKENS(str, "classifier_double")
}
`);
```
Expand Down Expand Up @@ -1061,16 +1062,17 @@ The *properties* allowed for this Analyzer are an object with the following attr

**Examples**

Create and use a `nearest_neighbors` Analyzer with a stored "cooking" classifier to find similar terms.
Create and use a `nearest_neighbors` Analyzer with a stored "cooking" classifier
to find similar terms.

```js
var analyzers = require("@arangodb/analyzers");
var nn_single = analyzers.save("nn_single", "nearest_neighbors", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin" }, ["frequency", "norm", "position"]);
var nn_top_two = analyzers.save("nn_double", "nearest_neighbors", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin", "top_k": 2 }, ["frequency", "norm", "position"]);
db._query(`LET str = 'salt, oil'
db._query(`LET str = "salt, oil"
RETURN {
"all": TOKENS(str, 'nn_single'),
"double": TOKENS(str, 'nn_double')
"all": TOKENS(str, "nn_single"),
"double": TOKENS(str, "nn_double")
}
`);
```
Expand Down
4 changes: 2 additions & 2 deletions 3.10/appendix-glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ the application path. The filesystem layout could look like this:
apps/ # the instance's application directory
system/ # system applications (can be ignored)
_db/ # sub-directory containing database-specific applications
<database-dir>/ # sub-directory for a single database
<database-dir>/ # sub-directory for a single database
<mountpoint>/APP # sub-directory for a single application
<mountpoint>/APP # sub-directory for a single application
<database-dir>/ # sub-directory for another database
<database-dir>/ # sub-directory for another database
<mountpoint>/APP # sub-directory for a single application
```

Expand Down
24 changes: 12 additions & 12 deletions 3.10/aql-tutorial-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ run by clicking **Execute**:

![Insert query in query editor](images/Query_Insert.png)

```js
```aql
INSERT {
"name": "Ned",
"surname": "Stark",
Expand Down Expand Up @@ -62,7 +62,7 @@ of strings. The entire document is an object.

Let's add a bunch of other characters in a single query:

```js
```aql
LET data = [
{ "name": "Robert", "surname": "Baratheon", "alive": false, "traits": ["A","H","C"] },
{ "name": "Jaime", "surname": "Lannister", "alive": true, "age": 36, "traits": ["A","F","B"] },
Expand Down Expand Up @@ -121,7 +121,7 @@ literal array definition like `[ {...}, {...}, ... ]`.
This variable is then used in the `INSERT` statement instead of a literal
object definition. What it does is basically:

```js
```aql
INSERT {
"name": "Robert",
"surname": "Baratheon",
Expand Down Expand Up @@ -154,7 +154,7 @@ There are a couple of documents in the *Characters* collection by now. We can
retrieve them all using a `FOR` loop again. This time however we use it to
go through all documents in the collection instead of an array:

```js
```aql
FOR c IN Characters
RETURN c
```
Expand Down Expand Up @@ -191,7 +191,7 @@ attributes starting with an underscore `_` are read-only.
We can use either the document key or the document ID to retrieve a specific
document with the help of an AQL function `DOCUMENT()`:

```js
```aql
RETURN DOCUMENT("Characters", "2861650")
// --- or ---
RETURN DOCUMENT("Characters/2861650")
Expand Down Expand Up @@ -219,7 +219,7 @@ Here, `"2861650"` is the key for the *Ned Stark* document, and `"2861653"` for

The `DOCUMENT()` function also allows you to fetch multiple documents at once:

```js
```aql
RETURN DOCUMENT("Characters", ["2861650", "2861653"])
// --- or ---
RETURN DOCUMENT(["Characters/2861650", "Characters/2861653"])
Expand Down Expand Up @@ -261,7 +261,7 @@ Update documents
According to our *Ned Stark* document, he is alive. When we get to know that he
died, we need to change the `alive` attribute. Let us modify the existing document:

```js
```aql
UPDATE "2861650" WITH { alive: false } IN Characters
```

Expand All @@ -270,7 +270,7 @@ specified document with the attributes listed (or adds them if they don't exist)
but leaves the rest untouched. To replace the entire document content, you may
use `REPLACE` instead of `UPDATE`:

```js
```aql
REPLACE "2861650" WITH {
name: "Ned",
surname: "Stark",
Expand All @@ -282,7 +282,7 @@ REPLACE "2861650" WITH {

This also works in a loop. For example, the following adds a new attribute to all documents:

```js
```aql
FOR c IN Characters
UPDATE c WITH { season: 1 } IN Characters
```
Expand All @@ -292,7 +292,7 @@ The query adds the `season` attribute to the documents' top level. You can
inspect the result by re-running the query that returns all documents in a
collection:

```js
```aql
FOR c IN Characters
RETURN c
```
Expand Down Expand Up @@ -335,13 +335,13 @@ Delete documents
To fully remove documents from a collection, there is the `REMOVE` operation.
It works similar to the other modification operations, yet without a `WITH` clause:

```js
```aql
REMOVE "2861650" IN Characters
```

It can also be used in a loop body to effectively truncate a collection:

```js
```aql
FOR c IN Characters
REMOVE c IN Characters
```
Expand Down
14 changes: 7 additions & 7 deletions 3.10/aql-tutorial-filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ conditions for documents to match.
Equality condition
------------------

```js
```aql
FOR c IN Characters
FILTER c.name == "Ned"
RETURN c
Expand All @@ -28,7 +28,7 @@ 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:

```js
```aql
FOR c IN Characters
FILTER c.surname == "Stark"
RETURN c
Expand All @@ -41,7 +41,7 @@ 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
adult characters:

```js
```aql
FOR c IN Characters
FILTER c.age >= 13
RETURN c.name
Expand Down Expand Up @@ -71,7 +71,7 @@ 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:

```js
```aql
FOR c IN Characters
FILTER c.age < 13
RETURN { name: c.name, age: c.age }
Expand Down Expand Up @@ -99,7 +99,7 @@ Multiple conditions
To not let documents pass the filter without an age attribute, we can add a
second criterion:

```js
```aql
FOR c IN Characters
FILTER c.age < 13
FILTER c.age != null
Expand All @@ -115,7 +115,7 @@ FOR c IN Characters

This could equally be written with a boolean `AND` operator as:

```js
```aql
FOR c IN Characters
FILTER c.age < 13 AND c.age != null
RETURN { name: c.name, age: c.age }
Expand All @@ -129,7 +129,7 @@ Alternative conditions
If you want documents to fulfill one or another condition, possibly for
different attributes as well, use `OR`:

```js
```aql
FOR c IN Characters
FILTER c.name == "Jon" OR c.name == "Joffrey"
RETURN { name: c.name, surname: c.surname }
Expand Down
6 changes: 3 additions & 3 deletions 3.10/aql-tutorial-geospatial.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ which you need to create first, then run the AQL query below:

![Create Locations collection](images/Locations_Collection_Creation.png)

```js
```aql
LET places = [
{ "name": "Dragonstone", "coordinate": [ 55.167801, -6.815096 ] },
{ "name": "King's Landing", "coordinate": [ 42.639752, 18.110189 ] },
Expand Down Expand Up @@ -75,7 +75,7 @@ to restrict the number of results to at most *n* matches.
In the example below, the limit is set to 3. The origin (the reference point) is
a coordinate somewhere in downtown Dublin, Ireland:

```js
```aql
FOR loc IN Locations
LET distance = DISTANCE(loc.coordinate[0], loc.coordinate[1], 53.35, -6.25)
SORT distance
Expand Down Expand Up @@ -124,7 +124,7 @@ Find locations within radius
locations within a given radius from a reference point. Remember that the unit
is meters. The example uses a radius of 200,000 meters (200 kilometers):

```js
```aql
FOR loc IN Locations
LET distance = DISTANCE(loc.coordinate[0], loc.coordinate[1], 53.35, -6.25)
SORT distance
Expand Down
Loading