Skip to content

Commit d1bebf3

Browse files
committed
Major checkpoint: many exercises added and a Playground component
1 parent dca727e commit d1bebf3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+510
-229
lines changed

docs/10_About_workshop/1_intro.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ the aggregation pipeline.
2626

2727
![Run button](/img/playground_run.png)
2828

29+
### Comments
30+
31+
In the QUERY pane, lines prefixed with `//` comment-out the line. This is a useful way to document your work, or to have some variations to play around with.
32+
33+
The DATA SOURCE pane also accepts the comment prefix.
34+
35+
### Error messages
36+
37+
Sometimes aren't related to the actual cause. Syntax errors can cause confusion in interpreting the pipeline, configuration, or data.
38+
39+
Step back with a leaner, cleaner working example and build back up carefully.
40+
41+
This is why a Playground is useful - mistakes andtypos happen. syntax is unforgiving.
42+
Error messages are our friend, giving us an opportunity to fix and learn iteratively in a safe environment.
43+
2944
## Resources
3045
* <Link to="https://www.mongodb.com/developer/products/atlas/search-playground-intro/">Atlas Search Playground: Easy Experimentation</Link> (article)
3146

docs/10_About_workshop/2_lets_go.mdx

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Exercise: Fix me
2+
3+
<Playground pid="6782aea0667feaaf06324b87">Fix me</Playground>
4+
5+
Here's a gentle first exercise to get you started with the playground.
6+
You'll see an index configuration and an aggregation pipeline stage that
7+
hasn't been introduced yet, but no worries -
8+
we'll get there next. See if you can solve it with what you already know or expect.
9+
10+
1. Navigate to this Playground snapshot linked above.
11+
2. Press "Run"
12+
3. Notice the empty array `[]` of results
13+
14+
The objective with this exercise is to adjust the `FIX_ME` in the `$search` aggregation pipeline stage so that the document (in the Data Source pane) matches the query and appears in the Results pane.
15+
16+
[![Playground intro exercise](/img/playground_intro_exercise.png)](/img/playground_intro_exercise.png)
17+
18+
<details>
19+
<summary>Here's a solution...</summary>
20+
<div>
21+
You can copy this pipeline and paste it in to the playground's Query panel and press Run.
22+
```js
23+
[
24+
{
25+
$search: {
26+
index: "default",
27+
text: {
28+
query: "search",
29+
path: "title"
30+
}
31+
}
32+
}
33+
]
34+
```
35+
</div>
36+
</details>
37+
38+
<details>
39+
<summary>There are other possible solutions too, such as:</summary>
40+
<div>
41+
`atlas` or `fundamentals` or other case variations of any `title` field words
42+
</div>
43+
</details>
44+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Exercise: My very first playground
2+
3+
Create a <Playground pid="new">new playground</Playground>.
4+
5+
Clear the data box in the lower left (select-all, delete), and then type, paste, or import an array of a few documents. You could copy/paste the below, for example:
6+
7+
```
8+
[
9+
{
10+
"_id": 1,
11+
"title": "mY vErY fIrSt PlAyGrOuNd"
12+
}
13+
]
14+
```
15+
16+
Now, in the upper left box, create an aggregation pipeline that uses `$search` as the first (and only, for now)
17+
stage. Here's one that matches that document with the default configuration:
18+
19+
```
20+
[
21+
{
22+
$search: {
23+
index: "default",
24+
text: {
25+
query: "my playground",
26+
path: "title"
27+
}
28+
}
29+
}
30+
]
31+
```
32+
Press Run!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"label": "👐 Exercises",
3+
"link": {
4+
"type": "generated-index"
5+
}
6+
}

docs/20_Intro_to_Atlas_Search/2_aggregation_stages.mdx

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# 👐 Aggregation pipeline search stages
1+
# 📘 Aggregation pipeline search stages
22

33
The search stages must be the first stage in a pipeline, as they do not accept incoming
44
documents but rather only emit documents. There are two stages available, depending on
5-
the particular needs.
5+
the particular needs.
6+
7+
* `index` name parameter: good idea to be explicit about it, otherwise `default`.
68

79
## $search
810

@@ -13,6 +15,9 @@ Results are returned in descending **score** order or in an optional `sort` orde
1315

1416
## $searchMeta
1517

18+
TODO: It was mentioned that searchMeta perhaps doesn't warrant (much) coverage in this
19+
workshop. Perhaps only mention but do no cover?
20+
1621
Returns a single document of search result metadata including count of matching documents
1722
and any facets requested. No actual collection documents are returned.
1823

@@ -22,58 +27,6 @@ Results metadata includes the count of matching results and facets.
2227
This same metadata is available when using `$search` too,
2328
accessible in the $$SEARCH_META context variable.
2429

25-
## Exercises: search pipeline stages
26-
27-
### Step 1
28-
1. Navigate to the original Playground used in the last section's exercise
29-
https://search-playground.mongodb.com/tools/code-sandbox/snapshots/6782aea0667feaaf06324b87
30-
2. Press Run. Got the empty `[]` array of results?
31-
3. Change `$search` to `$searchMeta` (in the Query pane), and press Run again.
32-
33-
<details>
34-
<summary>Here's the expected results...</summary>
35-
<div>
36-
```js
37-
[
38-
{
39-
"count": {
40-
"lowerBound": 0
41-
}
42-
}
43-
]
44-
```
45-
</div>
46-
</details>
47-
48-
### Step 2
49-
50-
1. Now fix the query to match the document as you did previously
51-
2. Press Run again
52-
3. Did the `$searchMeta` results change?
53-
54-
<details>
55-
<summary>Here's the expected results...</summary>
56-
<div>
57-
```js
58-
[
59-
{
60-
"count": {
61-
"lowerBound": 1
62-
}
63-
}
64-
]
65-
```
66-
</div>
67-
</details>
68-
69-
IMPORTANT: Always specify the `index` parameter. Otherwise it uses `default`(?) and if there's no
70-
index by that name, you get `[]` not an error. The Playground only has a `default` index.
71-
(and you get an error if you use any other name); be explicit.
72-
73-
"Yes I double checked that the index name matches." (forum user that has been bitten before)
74-
- https://www.mongodb.com/community/forums/t/no-documents-retrieved-using-dynamic-false/310123
75-
76-
7730
## Post $search-stages
7831

7932
* Such as $sort, $group, etc any stage that consumes **all** documents from previous stage.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Exercise: search pipeline stages
2+
3+
<Playground url="https://search-playground.mongodb.com/tools/code-sandbox/snapshots/6782aea0667feaaf06324b87">$search => $searchMeta</Playground>
4+
5+
# Step 1
6+
1. Navigate to the original Playground used in the last section's exercise
7+
2. Press Run. Got the empty `[]` array of results?
8+
3. Change `$search` to `$searchMeta` (in the Query pane), and press Run again.
9+
10+
<details>
11+
<summary>Here's the expected results...</summary>
12+
<div>
13+
```js
14+
[
15+
{
16+
"count": {
17+
"lowerBound": 0
18+
}
19+
}
20+
]
21+
```
22+
</div>
23+
</details>
24+
25+
# Step 2
26+
27+
1. Now fix the query to match the document as you did previously
28+
2. Press Run again
29+
3. Did the `$searchMeta` results change?
30+
31+
<details>
32+
<summary>Here's the expected results...</summary>
33+
<div>
34+
```js
35+
[
36+
{
37+
"count": {
38+
"lowerBound": 1
39+
}
40+
}
41+
]
42+
```
43+
</div>
44+
</details>
45+
46+
IMPORTANT: Always specify the `index` parameter. Otherwise it uses `default`(?) and if there's no
47+
index by that name, you get `[]` not an error. The Playground only has a `default` index.
48+
(and you get an error if you use any other name); be explicit.
49+
50+
"Yes I double checked that the index name matches." (forum user that has been bitten before)
51+
- https://www.mongodb.com/community/forums/t/no-documents-retrieved-using-dynamic-false/310123
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"label": "👐 Exercises",
3+
"link": {
4+
"type": "generated-index"
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 🦸 Deployment
2+
3+
## Local development environment
4+
5+
* https://www.mongodb.com/developer/products/atlas/getting-started-mongodb-atlas-local-search-experience-using-docker/
6+
7+

docs/30_Index_configuration/1_index_config.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Documents are indexed in Lucene using a flexible configuration specification.
77
The type of a field determines how it can be indexed, and thus how it can be searched.
88

99
Most field types are supported, including all the basic types such as booleans, dates, numerics,
10-
and strings, as well as ObjectID, UUID, GeoJSON. Null values are also supported implicitly.
10+
and strings, as well as ObjectID, UUID, GeoJSON types. Null values are also supported implicitly.
1111

1212
## Mapping
1313

@@ -18,7 +18,7 @@ both.
1818

1919
### Dynamic mapping
2020

21-
An index configuration defaults a fully dynamic mapping:
21+
An index configuration defaults to a fully dynamic mapping:
2222

2323
```
2424
{
@@ -70,6 +70,8 @@ Using that mapping, this document would only have the `in_stock` field indexed,
7070
}
7171
```
7272

73+
A field path/name can be mapped as an array of supported types. When the type of the document field matches an index mapping for that type, it will be indexed as appropriate for that particular type.
74+
7375
## Configuring an Atlas Search index
7476

7577
Outside of the Playground, you have several options to set up and configure a persistent

0 commit comments

Comments
 (0)