Skip to content

Commit f22f2fb

Browse files
authored
(DOCSP-32324) Adds info on how to create a view in the Atlas UI (#4872)
* (DOCSP-32324) Adds info on how to create a view in the Atlas UI * Moves content to the Materialized View page * Includes copy review changes * Includes copy review change
1 parent 2cf2be9 commit f22f2fb

File tree

3 files changed

+97
-4
lines changed

3 files changed

+97
-4
lines changed

source/core/materialized-views.txt

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ On-Demand Materialized Views
99
.. contents:: On this page
1010
:local:
1111
:backlinks: none
12-
:depth: 2
12+
:depth: 1
1313
:class: singlecol
1414

1515
.. meta::
@@ -36,6 +36,86 @@ Comparison with Standard Views
3636

3737
.. include:: /includes/views/fact-compare-view-and-materialized-view.rst
3838

39+
40+
.. _create-view-atlas:
41+
42+
Create a Materialized View in the {+atlas+} UI
43+
-------------------------------------------------------
44+
45+
The example in this section uses the :atlas:`sample movies dataset
46+
</sample-data/sample-mflix/>`. To learn how to load the sample dataset
47+
into your {+atlas+} deployment, see :atlas:`Load Sample Data
48+
</sample-data/#std-label-load-sample-data>`.
49+
50+
To create a materialized view in the {+atlas+} UI, follow these
51+
steps:
52+
53+
.. procedure::
54+
:style: normal
55+
56+
.. step:: Navigate to the collection
57+
58+
a. In the {+atlas+} UI, click :guilabel:`Database` in the sidebar.
59+
#. For the database deployment that contains the sample data,
60+
click :guilabel:`Browse Collections`.
61+
#. In the left navigation pane, select the
62+
:guilabel:`sample_training` database.
63+
#. Select the :guilabel:`grades` collection.
64+
65+
.. step:: Click the :guilabel:`Aggregation` tab
66+
67+
.. step:: Click :guilabel:`Add Stage`
68+
69+
.. step:: Select an aggregation stage from the :guilabel:`Select` drop-down menu
70+
71+
The aggregation stage transforms the data that you want to save as
72+
a view. To learn more about available aggregation stages, see
73+
:ref:`agg-pipeline-quick-ref`.
74+
75+
For this example, add a new field with the :pipeline:`$set` stage:
76+
77+
a. Select :pipeline:`$set` from the :guilabel:`Select` drop-down
78+
menu.
79+
#. Add the following syntax to the aggregation pipeline
80+
editor to create an average score across all ``score``
81+
values in the ``scores`` array within the ``grades``
82+
collection:
83+
84+
.. code-block::
85+
86+
{
87+
averageScore: { $avg: "$scores.score" }
88+
}
89+
90+
{+atlas+} adds the ``averageScore`` value to each document.
91+
92+
.. step:: Click :guilabel:`Add Stage`
93+
94+
.. step:: Add the ``$out`` stage
95+
96+
a. Select the :pipeline:`$out` stage from the :guilabel:`Select`
97+
drop-down menu.
98+
#. Add the following syntax to the aggregation pipeline
99+
to write the results of the pipeline to the ``myView``
100+
collection in the ``sample_training`` database:
101+
102+
.. code-block::
103+
104+
'myView'
105+
106+
#. Click :guilabel:`Save Documents`.
107+
108+
The :pipeline:`$out` stage writes the results of the
109+
aggregation pipeline to the specified collection, which creates
110+
the view. To learn more, see :pipeline:`$out`.
111+
112+
Refresh the list of collections to see the ``myView`` collection.
113+
114+
To learn how to query the ``myView`` collection in the {+atlas+}
115+
UI, see :atlas:`View, Filter, and Sort Documents
116+
</atlas-ui/documents/#view--filter--and-sort-documents>` in the
117+
{+atlas+} documentation.
118+
39119
Example
40120
-------
41121

source/core/views.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ computed on-demand when a client queries the view.
2525

2626
.. include:: /includes/views/disambiguate-standard-materialized.rst
2727

28+
.. |page-topic| replace:: create views
29+
.. |link-topic-ing| replace:: creating materialized views in the UI
30+
.. |atlas-url| replace:: :ref:`create-view-atlas`
31+
32+
.. include:: /includes/fact-atlas-compatible.rst
33+
.. include:: /includes/fact-atlas-link.rst
34+
2835
Use Cases
2936
---------
3037

@@ -46,8 +53,9 @@ You can use views to:
4653
Create and Manage Views
4754
-----------------------
4855

49-
To learn how to create and manage views, see the following pages:
56+
To learn how to create and manage views, see the following resources:
5057

58+
- :ref:`create-view-atlas`
5159
- :ref:`manual-views-create`
5260
- :ref:`manual-views-lookup`
5361
- :ref:`manual-views-collation`

source/core/views/create-view.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ Create and Query a View
1212
:depth: 2
1313
:class: singlecol
1414

15-
To create a view, use :method:`db.createCollection()` or
16-
:method:`db.createView()`.
15+
To create a view, use one of the following methods:
16+
17+
- Use :method:`db.createCollection()`
18+
- Use :method:`db.createView()`
19+
20+
To create a view in the {+atlas+} UI, you must use a materialized
21+
view. To learn more, see :ref:`create-view-atlas`.
1722

1823
.. important:: View Names are Included in Collection List Output
1924

0 commit comments

Comments
 (0)