Skip to content

Commit f4b07fd

Browse files
committed
checkpoint before delivery in Austin
1 parent 59842a6 commit f4b07fd

File tree

30 files changed

+465
-205
lines changed

30 files changed

+465
-205
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ yarn-debug.log*
2020
yarn-error.log*
2121

2222
/tmp
23+
/scratch

docs/10_About_workshop/1_intro.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 📘 Atlas Search Playground
22

3+
> I really like use of the Search playground. It’s fun to play with,
4+
> makes me feel good that I can figure out the answer,
5+
> and encourages me to tinker.
6+
37
The Atlas Search Playground (or just Playground) is used for the exercises in this workshop.
48
The Playground is a self-contained lightweight, yet feature-rich Atlas Search environment
59
which does not require an Atlas account to use.

docs/10_About_workshop/8_Exercises/1_.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Exercise: Fix me
22

3-
Here's a gentle first exercise to get you started with the playground.
3+
Here's a gentle first exercise to get us started with the playground.
44
You'll see an index configuration and an aggregation pipeline stage that
55
hasn't been introduced yet, but no worries -
66
we'll get there next. See if you can solve it with what you already know or expect.
77

8-
1. Navigate to this Playground snapshot linked above.
8+
We're going to work through this one together as a group.
9+
10+
1. Navigate to the Playground snapshot linked below.
911
2. Press "Run"
1012
3. Notice the empty array `[]` of results
1113

docs/20_Intro_to_Atlas_Search/8_Exercises/1_.mdx

Lines changed: 0 additions & 47 deletions
This file was deleted.

docs/20_Intro_to_Atlas_Search/8_Exercises/_category_.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# 🦸 Deployment
22

3-
## Local development environment
4-
5-
* https://www.mongodb.com/developer/products/atlas/getting-started-mongodb-atlas-local-search-experience-using-docker/
3+
* Separate search nodes for production: https://www.mongodb.com/blog/post/search-nodes-now-public-preview-performance-scale-dedicated-infrastructure
4+
* Local development environment: https://www.mongodb.com/developer/products/atlas/getting-started-mongodb-atlas-local-search-experience-using-docker/
65

76

docs/30_Index_configuration/5_string.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are several ways in which strings can be used:
1212
* Faceting (not covered in this workshop)
1313
* Highlighting (not covered in this workshop)
1414

15-
A BSON `string` field in your collection can be mapped into one or more of the string-supporting Atlas Search types. A `dynamic: true` mapping maps all `string` field in one way: as full-text fields analyzed with `lucene.standard`. This analyzed textual field type is called `string`. An Atlas Search field indexed as string can only be queried by certain operators meant for full text queries. However, let's first cover the most basic way a string field can be indexed and used: as-is. In order to index a string field as it's exact or normalized value and make use of `equals` and `in` operators to query it as the exact or normalized value, it must be statically mapped to type `token`.
15+
A BSON `string` field in your collection can be mapped into one or more of the string-supporting Atlas Search types. A `dynamic: true` mapping maps all `string` field in one way: as full-text fields analyzed with `lucene.standard`. This analyzed textual field type is called `string`. An Atlas Search field indexed as string can only be queried by certain operators meant for full text queries. However, let's first cover the most basic way a string field can be indexed and used: as-is. In order to index a string field as its exact or normalized value and make use of `equals` and `in` operators to query it as the exact or normalized value, it must be statically mapped to type `token`.
1616

1717
## `token`
1818

Lines changed: 119 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,127 @@
11
# Exercises: Basic types
22

33
## boolean
4-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1d80e97570c2714a07e0">`equals`</Playground> (<Playground url="https://search-playground.mongodb.com/tools/code-playground/snapshots/669e6ab1d49ef6fad98118b4">fixed</Playground>)
5-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1e53d0df60f0254e5d2b">`in`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c19c4e97570c2714a07dc">fixed</Playground>)
6-
4+
5+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1d80e97570c2714a07e0">`equals`</Playground>
6+
<details>
7+
<summary>Solution</summary>
8+
<div>
9+
```js
10+
path: "in_stock"
11+
```
12+
13+
<Playground url="https://search-playground.mongodb.com/tools/code-playground/snapshots/669e6ab1d49ef6fad98118b4">boolean `equals` fixed</Playground>
14+
</div>
15+
</details>
16+
17+
18+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1e53d0df60f0254e5d2b">`in`</Playground>
19+
<details>
20+
<summary>Solution</summary>
21+
<div>
22+
```js
23+
value: [true, false]
24+
```
25+
26+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c19c4e97570c2714a07dc">boolean `in` fixed</Playground>
27+
</div>
28+
</details>
29+
30+
731
## date
8-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1b0fe97570c2714a07de">`equals`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c20a4d0df60f0254e5d2d">fixed</Playground>)
9-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1b5fd0df60f0254e5d27">`in`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c210ee97570c2714a07e2">fixed</Playground>)
10-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c21c8d0df60f0254e5d2f">`range`</Playground> (<Playground url="https://search-playground.mongodb.com/tools/code-playground/snapshots/669e6b18d49ef6fad98118b6">fixed</Playground>)
32+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1b0fe97570c2714a07de">`equals`</Playground>
33+
<details>
34+
<summary>Solution</summary>
35+
<div>
36+
```js
37+
value: ISODate("2023-11-01T00:00:00.000Z")
38+
```
39+
40+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c20a4d0df60f0254e5d2d">date `equals` fixed</Playground>
41+
</div>
42+
</details>
43+
44+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c1b5fd0df60f0254e5d27">`in`</Playground>
45+
<details>
46+
<summary>Solution</summary>
47+
<div>
48+
```js
49+
value: [ISODate("2024-02-01T00:00:00.000Z"), ISODate("2023-11-01T00:00:00.000Z"), ISODate("2007-12-25T00:00:00.000Z")]
50+
```
51+
52+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c210ee97570c2714a07e2">date `in` fixed</Playground>
53+
</div>
54+
</details>
55+
56+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c21c8d0df60f0254e5d2f">`range`</Playground>
57+
<details>
58+
<summary>Solution</summary>
59+
<div>
60+
```js
61+
path: "published_date"
62+
```
63+
<Playground url="https://search-playground.mongodb.com/tools/code-playground/snapshots/669e6b18d49ef6fad98118b6">date `range` fixed</Playground>
64+
</div>
65+
</details>
66+
1167

1268
## number
13-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c25abd0df60f0254e5d35">`equals`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c25e2d0df60f0254e5d37">fixed</Playground>)
14-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c252ce97570c2714a07e6">`in`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2569d0df60f0254e5d33">fixed</Playground>)
15-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2313d0df60f0254e5d31">`range`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c22bde97570c2714a07e4">fixed</Playground>)
69+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c25abd0df60f0254e5d35">`equals`</Playground>
70+
<details>
71+
<summary>Solution</summary>
72+
<div>
73+
```js
74+
path: "price"
75+
```
76+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c25e2d0df60f0254e5d37">number `equals` fixed</Playground>
77+
</div>
78+
</details>
79+
80+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c252ce97570c2714a07e6">`in`</Playground>
81+
<details>
82+
<summary>Solution</summary>
83+
<div>
84+
```js
85+
value: [19.99, 37.5]
86+
```
87+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2569d0df60f0254e5d33">number `in` fixed</Playground>
88+
</div>
89+
</details>
90+
91+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2313d0df60f0254e5d31">`range`</Playground> (fix two issues, not just one!)
92+
<details>
93+
<summary>Solution</summary>
94+
<div>
95+
```js
96+
range: {
97+
path: "price",
98+
gte: 15.00,
99+
lte: 25.00
100+
}
101+
```
102+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c22bde97570c2714a07e4">number `range` fixed</Playground>
103+
</div>
104+
</details>
16105

17106
## ObjectId
18-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c265dd0df60f0254e5d39">`equals`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962d77aa132ffc76719f53">fixed</Playground>)
19-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c26d5d0df60f0254e5d3b">`in`</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c270cd0df60f0254e5d3d">fixed</Playground>)
107+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c265dd0df60f0254e5d39">`equals`</Playground>
108+
<details>
109+
<summary>Solution</summary>
110+
<div>
111+
```js
112+
value: ObjectId("5a9427648b0beebeb69589a1")
113+
```
114+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962d77aa132ffc76719f53">ObjectId `equals` fixed</Playground>
115+
</div>
116+
</details>
117+
118+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c26d5d0df60f0254e5d3b">`in`</Playground>
119+
<details>
120+
<summary>Solution</summary>
121+
<div>
122+
```js
123+
value: [ObjectId("ba94c7648b0beebeb69589a1"), ObjectId("5a9427648b0beebeb69589a1")]
124+
```
125+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c270cd0df60f0254e5d3d">ObjectId `in` fixed</Playground>
126+
</div>
127+
</details>
Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
# Exercises: Type mismatches
22

3-
Atlas Search is quite type sensitive. The BSON type of each field is used to determine which index mapping type to use. And at query time, the type of `value` or `query` is used to determine which index to query for a particular field/path name.
3+
Atlas Search is quite type sensitive. The BSON type of each field is used to determine which index mapping type to use. And at query time, the search operator type of `value` is used to determine which index to query for a particular field/path name.
44

55
## boolean
66
Why doesn't this playground match as expected?
7-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dfdaa132ffc76719f57">boolean type mismatch</Playground>
7+
8+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dfdaa132ffc76719f57">boolean type mismatch</Playground>
89

9-
<details>
10-
<summary>Explanation</summary>
11-
<div>
12-
The type of `$search.equals.value` is not an actual boolean (it's a `string` of "true") and thus will be looking for an indexed value corresponding that type (which in this case would be a `token` search type).
10+
<details>
11+
<summary>Explanation</summary>
12+
<div>
13+
The type of `$search.equals.value` is not an actual boolean (it's a `string` of "true") and thus will be looking for an indexed value corresponding that type (which in this case would be a `token` field type).
1314

14-
Here's a corrected pipeline:
15-
```js
16-
[
17-
{
18-
$search: {
19-
index: "default",
20-
equals: {
21-
value: true,
22-
path: "in_stock"
23-
}
15+
Here's a corrected pipeline:
16+
```js
17+
[
18+
{
19+
$search: {
20+
index: "default",
21+
equals: {
22+
value: true,
23+
path: "in_stock"
2424
}
2525
}
26-
]
26+
}
27+
]
28+
```
29+
</div>
30+
</details>
31+
32+
## number
33+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962e2faa132ffc76719f5b">number type mismatch</Playground>
34+
<details>
35+
<summary>Solution</summary>
36+
<div>
37+
The value must be a number, not a string.
38+
39+
```js
40+
value: 10.99
2741
```
2842
</div>
29-
</details>
43+
</details>
3044

31-
## number
32-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962e2faa132ffc76719f5b">number type mismatch</Playground>
3345

3446
## ObjectID
35-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dc7aa132ffc76719f55">ObjectID type mismatch</Playground>
47+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dc7aa132ffc76719f55">ObjectId type mismatch</Playground>
48+
<details>
49+
<summary>Solution</summary>
50+
<div>
51+
The value must be an ObjectId, not a string.
52+
53+
```js
54+
value: ObjectId("5a9427648b0beebeb69589a1")
55+
```
56+
</div>
57+
</details>
3658

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# Exercises: `token` type
22

3-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2fedd0df60f0254e5d3f">`equals` on `string` mismatch</Playground> (<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c3028d0df60f0254e5d41">fixed</Playground>) The `token` type must be manually/statically mapped; it is not dynamically mapped.
4-
* `in`/`range` (TODO)
5-
3+
Refer back to the `string` section above for details on configuring the `token` field type.
4+
5+
## `equals` on strings
6+
7+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c2fedd0df60f0254e5d3f">`equals` on `string` mismatch</Playground>
8+
<details>
9+
<summary>Solution</summary>
10+
<div>
11+
The `token` type must be manually/statically mapped; it is not dynamically mapped.
12+
13+
```js
14+
{
15+
"mappings": {
16+
"dynamic": true,
17+
"fields": {
18+
"category": [
19+
{
20+
"type": "token"
21+
}
22+
]
23+
}
24+
}
25+
}
26+
```
27+
<Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/679c3028d0df60f0254e5d41">token type `equals` fixed</Playground>
28+
</div>
29+
</details>
30+
31+
## `in` and `range` on strings
32+
Similarly, the `token` field type is needed to do `in` and `range` queries on exact strings.

0 commit comments

Comments
 (0)