Skip to content

Commit 562265e

Browse files
committed
Last pre-dry run checkpoint commit, exercises everywhere
1 parent 8fc51d7 commit 562265e

File tree

22 files changed

+208
-83
lines changed

22 files changed

+208
-83
lines changed

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

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

3-
<Playground pid="6782aea0667feaaf06324b87">Fix me</Playground>
3+
Here's a gentle first exercise to get you started with the playground.
4+
You'll see an index configuration and an aggregation pipeline stage that
5+
hasn't been introduced yet, but no worries -
6+
we'll get there next. See if you can solve it with what you already know or expect.
47

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.
8+
1. Navigate to this Playground snapshot linked above.
9+
2. Press "Run"
10+
3. Notice the empty array `[]` of results
911

10-
1. Navigate to this Playground snapshot linked above.
11-
2. Press "Run"
12-
3. Notice the empty array `[]` of results
12+
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.
1313

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.
14+
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/6782aea0667feaaf06324b87">Playground: Fix me</Playground>
1515

1616
[![Playground intro exercise](/img/playground_intro_exercise.png)](/img/playground_intro_exercise.png)
1717

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Exercise: My very first playground
22

3-
Create a <Playground pid="new">new playground</Playground>.
3+
Create a <Playground url="https://search-playground.mongodb.com/tools/code-sandbox/snapshots/new">new playground</Playground>.
44

55
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:
66

@@ -29,4 +29,11 @@ stage. Here's one that matches that document with the default configuration:
2929
}
3030
]
3131
```
32-
Press Run!
32+
Press Run!
33+
34+
## Your playground, your data
35+
36+
At this point, experiment for a moment - click around, adjust the data to something of interest and
37+
see if you can get a `$search` query to match.
38+
39+
It's meant to break, without breaking anything else. What happened? Was there an error message or unexpected empty `[]` results? No worries.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,4 @@
4444
</details>
4545

4646
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
47+
index by that name, you get `[]` not an error. The Playground only has a `default`-named index. (and you get an error if you use any other name); be explicit.

docs/30_Index_configuration/1_index_config.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ and options available.
8787

8888
## Resources
8989

90-
* https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/
90+
* <Link to="https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/">Define field mappings (docs)</Link>
91+
* Type mismatch detail can make or break your pipeline, e.g. https://www.mongodb.com/community/forums/t/no-documents-retrieved-using-dynamic-false/310123/3

docs/30_Index_configuration/3_geo.mdx

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

docs/30_Index_configuration/8_Exercises/2_.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
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.
44

5-
Why don't this playground match as expected?
5+
## boolean
6+
Why doesn't this playground match as expected?
67
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dfdaa132ffc76719f57">boolean type mismatch</Playground>
7-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962e2faa132ffc76719f5b">number ype mismatch</Playground>
8-
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dc7aa132ffc76719f55">ObjectID type mismatch</Playground>
98

109
<details>
1110
<summary>Explanation</summary>
1211
<div>
13-
Because $search.equals.value is a string of "true", not an actual boolean.
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).
13+
1414
Here's a corrected pipeline:
1515
```js
1616
[
@@ -28,5 +28,9 @@ Why don't this playground match as expected?
2828
</div>
2929
</details>
3030

31-
IMPORTANT: Type matters. This detail can make or break your pipeline:
32-
e.g. https://www.mongodb.com/community/forums/t/no-documents-retrieved-using-dynamic-false/310123/3
31+
## number
32+
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962e2faa132ffc76719f5b">number type mismatch</Playground>
33+
34+
## ObjectID
35+
* <Playground url="https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/67962dc7aa132ffc76719f55">ObjectID type mismatch</Playground>
36+

docs/30_Index_configuration/9_advanced.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
# 🦸 Advanced
22

3+
## Geo-spatial fields
4+
5+
Dynamic mapping does not support geo-spatial fields, and require a manual/static mapping configuration.
6+
7+
Here's a document with a `Point` field:
8+
```
9+
{
10+
_id: 1,
11+
city: "Charlottesville",
12+
location: {
13+
type: "Point",
14+
coordinates: [-78.47668,38.02931]
15+
}
16+
}
17+
```
18+
19+
To map that GeoJSON `location` field to a `geo` type in Atlas Search:
20+
```
21+
{
22+
"mappings": {
23+
"dynamic": true,
24+
"fields": {
25+
"location": {
26+
"type": "geo"
27+
}
28+
}
29+
}
30+
}
31+
```
32+
33+
34+
35+
### geo-spatial search operators
36+
37+
* <Link to="https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/">geoWithin</Link>
38+
- <Playground url="https://search-playground.mongodb.com/tools/code-playground/snapshots/669e6b762ce7658e786edbfa">geoWithin playground</Playground>
39+
* <Link to="https://www.mongodb.com/docs/atlas/atlas-search/geoShape/">geoShape</Link>
40+
* <Link to="https://www.mongodb.com/docs/atlas/atlas-search/near/">near</Link>
41+
342
## `near` operator
443

544
Operates on numbers and dates, but trickier than `equals`, `in`, and `range`

docs/50_Querying/1_index.mdx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
# 📘 Query construction
1+
# 📘 Text search operators
22

33
We've already seen and played with the bulk of non-string
4-
operators, which operate straightforwardly. Let's now turn our attention to the
5-
two main `string` type operators.
4+
operators, which operate straightforwardly.
5+
6+
Let's now turn our attention to the various `string` type operators.
7+
8+
## Analysis refresher
9+
10+
Your documents `string` fields are analyzed during indexed. Search operators on string fields navigate the inverted index structure for matches. In order to match the terms as they were indexed, string operators analyze query text, just as field text is analyzed during indexing.
11+
12+
## `text`
13+
14+
To query for individual terms, or words, of a `string` field.
15+
16+
If the `query` text analyzes to more than one term, the query either makes all terms optional (default) or all terms mandatory (`matchCriteria: "all"`).
17+
18+
### fuzzy matching
19+
20+
The `fuzzy` parameter to the `text` operator allows terms to be matched a bit looser, such that small changes such as a single missing letter, or two letters transcribed, or a letter or two different.
21+
22+
The easiest way to make a text search fuzzy is by adding `"fuzzy": {}`. There are several nuanced options that can be set within that empty fuzzy document structure, but for now let's just go with the defaults provided by this simple addition.
23+
24+
## `phrase`
25+
26+
The `phrase` operator matches a sequence of words, in proximity to one another. By default,
27+
the words must match in the same order with no additional words in between, in other words an "exact phrase" match. Again, analysis is performed on the `query` to extract and analyze the terms in the same manner as they were indexed.
28+
29+
### phrase slop
30+
31+
A phrase match can be a bit loose, such that it can match even if there are additional words in between the query terms in the actual documents, or if the query terms are not in the same order, but within a certain proximity. This looseness factor for `phrase` searches is called "slop" (blame Lucene for the terminology). A non-zero, positive, value will allow for that number of additional terms or out of order'ness. The score of a sloppy `phrase` clause is greater when the match is less "sloppy" (the indexed terms are closer to matching the query), and less when the match is "sloppier".
32+
33+
## synonyms
34+
635

docs/50_Querying/3_string_operators.mdx

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
# 📘 Wildcard and Regex queries
22

3+
Both of these operators share ...
4+
5+
## Analyzer considerations
6+
37
Analyzer determines what is matchable.
48
`lucene.keyword` to match across the entire string.
59
Any other analyzer to match across the pieces of
610
its output.
711

8-
Prefix matters - index scan, or only prefix-matching
9-
slice scanned.
12+
Static prefix matters: index scan, or only prefix-matching slice scanned.
13+
14+
## `wildcard`
15+
16+
The `wildcard` operator supports two *wildcard* characters, `?` and `*` which can be placed anywhere
17+
in the query string, one or more of them.
18+
19+
* `?`: Matches any single character
20+
* `*`: Matches zero or more characters
21+
22+
## `regex`
23+
24+
The `regex` operator supports a robust regular expression syntax, able to match sophisticated patterns against the terms of an inverted index.
1025

11-
https://search-playground.corp.mongodb.com/tools/code-sandbox/snapshots/6798adcc28f1e0d8abe42e83
26+
* <Link to="https://www.mongodb.com/docs/atlas/atlas-search/regex/#lucene-regular-expression-behavior">Lucene regular expression behavior</Link>

0 commit comments

Comments
 (0)