Skip to content

Commit d93b82b

Browse files
authored
Merge pull request #216 from lmkerbey-mdb/DOCSP-24786
(DOCSP-24786) Create Atlas Search guides
2 parents f267f77 + 2002374 commit d93b82b

File tree

10 files changed

+562
-13
lines changed

10 files changed

+562
-13
lines changed

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
'.. |copy| unicode:: U+000A9',
5959
'.. |year| replace:: {0}'.format(datetime.date.today().year),
6060
'.. |ent-build| replace:: MongoDB Enterprise',
61+
'.. |fts| replace:: Atlas Search',
6162
])
6263

6364
source_constants = {

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ guides-db = "sample_guides"
2323
guides-coll = "planets"
2424
full-java-version = "4.7.0"
2525
full-dotnet-version = "2.17.0"
26+
fts = "Atlas Search"

source/atlas/sample-data.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,7 @@ Procedure
3838
.. procedure::
3939
:style: normal
4040

41-
.. step:: Navigate to the {+db-deployments+} page for your project.
42-
43-
.. step:: Click on your cluster name.
44-
45-
.. figure:: /images/sample-data-cluster.png
46-
:figwidth: 600px
47-
:alt: sample-data-cluster
48-
49-
.. step:: Click the :guilabel:`Collections` tab.
50-
51-
.. figure:: /images/sample-data-tab.png
52-
:figwidth: 600px
53-
:alt: sample-data-tab
41+
.. include:: /includes/navigate_to_collections.rst
5442

5543
.. step:: Click :guilabel:`Load Sample Dataset`.
5644

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.. procedure::
2+
:style: connected
3+
4+
.. step:: In the right-hand pane, click ``sample_supplies``,
5+
then click the ``sales`` collection.
6+
7+
.. step:: Click :guilabel:`Search Indexes` in the upper right
8+
of the collection preview pane.
9+
10+
.. step:: Click
11+
:guilabel:`Create Search Index`.
12+
13+
.. step:: Click the :guilabel:`Visual Editor` configuration
14+
method, then click :guilabel:`Next`.
15+
16+
.. step:: Review the :guilabel:`Database and Collection` list to
17+
ensure that ``sample_supplies.sales`` is selected, then click
18+
:guilabel:`Next`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. step:: Navigate to the {+db-deployments+} page for your project.
2+
3+
.. step:: Click on your cluster name.
4+
5+
.. figure:: /images/sample-data-cluster.png
6+
:figwidth: 600px
7+
:alt: sample-data-cluster
8+
9+
.. step:: Click
10+
the :guilabel:`Collections` tab.
11+
12+
.. figure:: /images/sample-data-tab.png
13+
:figwidth: 600px
14+
:alt: sample-data-tab

source/index.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,15 @@ Start with Guides
4949
.. guide:: /crud/update.txt
5050
.. guide:: /crud/delete.txt
5151

52+
.. chapter:: Atlas Search
53+
:description: Learn how to create Atlas Search indexes
54+
and run queries to perform relevance-based search on your
55+
data sets.
56+
57+
.. guide:: /search/dynamic.txt
58+
.. guide:: /search/static.txt
59+
.. guide:: /search/compound.txt
60+
.. guide:: /search/facet.txt
61+
5262
..
5363
.. include:: /chapters/aggregation.rst

source/search/compound.txt

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
:template: guide
2+
3+
.. _guide-search-compound:
4+
5+
===================================
6+
Querying with the Compound Operator
7+
===================================
8+
9+
.. default-domain:: mongodb
10+
11+
.. contents:: On this page
12+
:local:
13+
:backlinks: none
14+
:depth: 1
15+
:class: singlecol
16+
17+
Overview
18+
--------
19+
20+
.. short-description::
21+
22+
Retrieve documents in MongoDB with a query on multiple fields.
23+
24+
In this guide, you will learn how to use multiple search operators in
25+
a compound query using the aggregation pipeline.
26+
27+
.. time:: 15
28+
29+
What You'll Need
30+
----------------
31+
32+
- A MongoDB account. See :ref:`guides-create-atlas-account`.
33+
- An Atlas cluster. See :ref:`guides-create-a-cluster`.
34+
- Sample datasets :ref:`loaded into your cluster <guides-load-sample-data>`.
35+
- A search index with default settings and dynamic indexing. See
36+
:ref:`guides-search-dynamic`.
37+
38+
Procedure
39+
---------
40+
41+
.. procedure::
42+
:style: normal
43+
44+
.. include:: /includes/navigate_to_collections.rst
45+
46+
.. step:: In the right-hand pane, click ``sample_supplies``,
47+
then click the ``sales`` collection.
48+
49+
.. step:: Run a query on your index using the Aggregation Pipeline.
50+
51+
.. procedure::
52+
:style: connected
53+
54+
.. step:: Click
55+
the :guilabel:`Aggregation` tab.
56+
57+
.. step:: If you do not see a pipeline with an initial
58+
stage window in the right pane, click
59+
:guilabel:`Create New` and select :guilabel:`Pipeline`.
60+
61+
.. step:: In the stage window, click on the dropdown menu
62+
labeled :guilabel:`Select...` and select the
63+
:guilabel:`$search` stage.
64+
65+
.. step:: Replace the placeholder code with the following
66+
``compound`` operator:
67+
68+
.. code-block:: json
69+
70+
{
71+
"compound": {
72+
"filter": [{
73+
"text": {
74+
"query": "Online",
75+
"path": "purchaseMethod"
76+
}
77+
}],
78+
"should": [{
79+
"text": {
80+
"query": "notepad",
81+
"path": "items"
82+
}
83+
}]
84+
}
85+
}
86+
87+
.. step:: Review the results of the compound search in the
88+
right-hand pane. Your results should include the fields listed
89+
in the following sample document.
90+
91+
.. note::
92+
93+
The fields will not always appear in the same order
94+
for every returned document.
95+
96+
.. code-block:: json
97+
:copyable: false
98+
99+
items: Array
100+
storeLocation: "Denver"
101+
customer: Object
102+
couponUsed: false
103+
purchaseMethod: "Online"
104+
_id: ObjectID('5bd761dcae323e45a93cd06e')
105+
saleDate: 2013-11-22T18:49:45.212+00:00
106+
107+
You can expand ``Array`` and ``Object`` fields to view their
108+
contents by clicking on them.
109+
110+
Due to the ``filter`` operator, only records with a
111+
``purchaseMethod`` value of ``Online`` appear.
112+
Additionally, due to the ``should`` operator,
113+
records with an ``items`` value of ``notepad`` score
114+
higher than those without.
115+
116+
You now have a ``$search`` aggregation stage with a compound
117+
search definition.
118+
119+
Summary
120+
-------
121+
122+
If you successfully completed the procedure in this guide, you have
123+
created an Atlas Search aggregation stage with a compound operator,
124+
and have seen how different clauses in the operator interact to
125+
focus your search results across multiple axes. In the next guide, you
126+
will learn how to group search results using facets.
127+
128+
.. guide-next::

source/search/dynamic.txt

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
:template: guide
2+
3+
.. _guides-search-dynamic:
4+
5+
=====================
6+
Build a Dynamic Index
7+
=====================
8+
9+
.. default-domain:: mongodb
10+
11+
.. contents:: On this page
12+
:local:
13+
:backlinks: none
14+
:depth: 1
15+
:class: singlecol
16+
17+
Overview
18+
--------
19+
20+
.. short-description::
21+
22+
Retrieve documents in MongoDB with full-text search.
23+
24+
In this guide, you will learn how to create a search index
25+
for relevance-based search as an alternative to document-based search.
26+
27+
.. time:: 15
28+
29+
What You'll Need
30+
----------------
31+
32+
- A MongoDB account. See :ref:`guides-create-atlas-account`.
33+
- An Atlas cluster. See :ref:`guides-create-a-cluster`.
34+
- Sample datasets :ref:`loaded into your cluster <guides-load-sample-data>`.
35+
36+
Procedure
37+
---------
38+
39+
.. procedure::
40+
:style: normal
41+
42+
.. include:: /includes/navigate_to_collections.rst
43+
44+
.. step:: Create a dynamic search index.
45+
46+
.. include:: /includes/create_index_sample_sales.rst
47+
48+
.. step:: Click :guilabel:`Create Search Index`. Wait for the
49+
:guilabel:`Status` column to read :guilabel:`Active`.
50+
51+
You now have a search index definition. This definition
52+
recursively indexes fields of
53+
:ref:`many common data types <bson-data-chart>` across indexed
54+
documents.
55+
56+
.. step:: Click :guilabel:`QUERY`
57+
in the :guilabel:`Actions` column of your index definition.
58+
59+
.. step:: Run a query on your index.
60+
61+
.. procedure::
62+
:style: connected
63+
64+
.. step:: Type ``notepad`` into the search bar, then click
65+
:guilabel:`Search`.
66+
67+
.. step:: Review the results.
68+
69+
Your results should include the fields listed in the following
70+
sample documents.
71+
72+
.. code-block:: json
73+
:copyable: false
74+
75+
SCORE: 0.20185701549053192
76+
salesDate: 2013-03-07T09:27:58.283+00:00
77+
items: Array
78+
storeLocation: "Austin"
79+
80+
SCORE: 0.20185701549053192
81+
salesDate: 2013-05-05T19:03:06.358+00:00
82+
items: Array
83+
storeLocation: "London"
84+
85+
SCORE: 0.20185701549053192
86+
salesDate: 2016-06-20T14:09:52.408+00:00
87+
items: Array
88+
storeLocation: "Denver"
89+
90+
Each record also includes a :ref:`relevance score <scoring-ref>`.
91+
You can expand ``Array`` and ``Object`` fields to view their
92+
contents by clicking on them.
93+
94+
.. step:: Click :guilabel:`Edit Query Syntax`. The modal window
95+
displays the query sent through the {+fts+} API.
96+
97+
Summary
98+
-------
99+
100+
If you successfully completed the procedure in this guide, you have
101+
created an Atlas Search index with dynamic field mappings and used it
102+
to perform a relevance-based query against the
103+
``sample_supplies.sales`` collection. In the next guide, you will learn
104+
how to perform a refined search by creating an index with static field
105+
mappings.
106+
107+
.. guide-next::

0 commit comments

Comments
 (0)