Skip to content

Commit 66bd2f9

Browse files
lindseymoorerachel-mackjordan-smith721norareidyshuangela
authored
Merge Feature/docsp 51411 rubycc (#14735)
* [Ruby] TOC Reorg (#160) * toc reorg * tweaks * DOCSP-51415 Add causal consistency section (#161) * [Ruby] CRUD - Upsert (#164) * DOCSP-51932: v2.21.2 patch release (#163) * add upsert section * reference * LM feedback * checkout snooty --------- Co-authored-by: Nora Reidy <[email protected]> * change TOC name (#165) (#167) * DOCSP-51416 Network Compression (#162) * [Ruby] Load Balancers (#166) * DOCSP-51932: v2.21.2 patch release (#163) * client option * undo snooty change * formatting * formatting * DR feedback --------- Co-authored-by: Nora Reidy <[email protected]> * [Ruby] Extended JSON (#168) * DOCSP-51932: v2.21.2 patch release (#163) * shared content * write * link formatting * link formatting * NR feedback * NR feedback * JB feedback * rephrase * remove extra change --------- Co-authored-by: Nora Reidy <[email protected]> * Rebase comp-cov for monorepo migration (#170) * DOCSP-51932: v2.21.2 patch release (#163) * change TOC name (#165) * add a redirect (#169) * [Ruby] TOC Reorg (#160) * toc reorg * tweaks * DOCSP-51415 Add causal consistency section (#161) * [Ruby] CRUD - Upsert (#164) * DOCSP-51932: v2.21.2 patch release (#163) * add upsert section * reference * LM feedback * checkout snooty --------- Co-authored-by: Nora Reidy <[email protected]> * DOCSP-51416 Network Compression (#162) * [Ruby] Load Balancers (#166) * DOCSP-51932: v2.21.2 patch release (#163) * client option * undo snooty change * formatting * formatting * DR feedback --------- Co-authored-by: Nora Reidy <[email protected]> * [Ruby] Extended JSON (#168) * DOCSP-51932: v2.21.2 patch release (#163) * shared content * write * link formatting * link formatting * NR feedback * NR feedback * JB feedback * rephrase * remove extra change --------- Co-authored-by: Nora Reidy <[email protected]> --------- Co-authored-by: Nora Reidy <[email protected]> Co-authored-by: shuangela <[email protected]> Co-authored-by: Jordan Smith <[email protected]> * DOCSP-51431 Clarify AVS mentions (#13632) * DOCSP-51432 Clarify AVS mentions * edit and trial deployment * edits and try staging * edit and will deploy work? * AS edits * DOCSP-51423 Logging (#13760) * DOCSP-51423 Logging * edits * edits * last edits * texh review * remove highlightign and add api links * api refs * DOCSP-51425 DNS Service Discovery (#14016) * DOCSP-51417 Connection Pools (#13897) * DOCSP-51417 Connection Pools * add to options page * edits * edits * add code files- JS review * tech review * edit * DOCSP-51427 Retryable reads and writes (#14181) * DOCSP-51424 Monitoring (#14104) * DOCSP-51424 Monitoring * 1st draft * tech review * reformat SDAM table * NR review * small edit * edits * DOCSP-53424 Update TOC Config (#14212) * DOCSP-53424 Update TOC Config * edit and test preview * edit and try preview * MM review * DOCSP-51426 Add Configure CRUD page (#14232) * DOCSP-51426 Add Configure CRUD page * test deploy * edit toc for page * DOCSP-51474 Break up common errors page (#14314) * [Ruby CC] Atlas Search (#14318) * atlas search * add to toc * update link * update link * LM feedback * DOCSP-51430 Server Selection (#14300) * DOCSP-51430 Server Selection * code examples * add toc * edits * revise ex section * Edits * edit * Edits * RM review * fix api link * tech review * edits * edit * remove selector from connection options * edits * edits * last edits * DOCSP-51432 Clean up CC (#14460) * DOCSP-51432 Clean up CC * finish reviewing toc * query section * rest of redirects * titles and edits * page titles * edits * fix toc trees * edit * more toctree fixes * text build * testing aws lambda url * SA review * fix connect changes * fix merge conflicts * conflict toc * remove exta data formatss ection * SA review --------- Co-authored-by: Rachel Mackintosh <[email protected]> Co-authored-by: Jordan Smith <[email protected]> Co-authored-by: Nora Reidy <[email protected]> Co-authored-by: shuangela <[email protected]> Co-authored-by: anabellabuckvar <[email protected]> Co-authored-by: Stephanie <[email protected]>
1 parent 953ccc5 commit 66bd2f9

Some content is hidden

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

70 files changed

+1920
-855
lines changed

content/ruby-driver/current/snooty.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name = "ruby-driver"
22
title = "Ruby Driver"
33
toc_landing_pages = [
4-
"/get-started",
5-
"/read",
6-
"/write",
4+
"/connect/connection-options",
5+
"/crud/query",
76
"/indexes",
8-
"/databases-collection",
9-
"/security/authentication",
7+
"/security/authentication"
108
]
119

1210
intersphinx = ["https://www.mongodb.com/docs/manual/objects.inv"]
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
.. _ruby-atlas-search:
2+
3+
=========================
4+
Run an Atlas Search Query
5+
=========================
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: reference
16+
17+
.. meta::
18+
:keywords: search, atlas, read
19+
20+
Overview
21+
--------
22+
23+
In this guide, you can learn how to query an Atlas Search index and use advanced full-text
24+
search functionality in your {+driver-short+} applications. You can query a search index by
25+
using a ``$search`` aggregation pipeline stage.
26+
27+
To learn more about the ``$search`` pipeline stage, see the :manual:`$search
28+
</reference/operator/aggregation/search/>` guide in the {+mdb-server+} manual.
29+
30+
.. note:: Only Available on Atlas for MongoDB v4.2 and Later
31+
32+
The ``$search`` aggregation-pipeline operator is available only for collections hosted
33+
on :atlas:`MongoDB Atlas </>` clusters running MongoDB v4.2 or later that are
34+
covered by an :atlas:`Atlas search index </reference/atlas-search/index-definitions/>`.
35+
To learn more about the required setup and the functionality of this operator,
36+
see the :atlas:`Atlas Search </atlas-search>` documentation.
37+
38+
Sample Data
39+
~~~~~~~~~~~
40+
41+
The examples in this guide use the ``sample_mflix.movies`` collection
42+
from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to create a
43+
free MongoDB Atlas cluster and load the sample datasets, see
44+
:ref:`<ruby-get-started>`.
45+
46+
Create an Atlas Search Index
47+
----------------------------
48+
49+
Before you can perform a search on an Atlas collection, you must first create an **Atlas
50+
Search index** on the collection. An Atlas Search index is a data structure that
51+
categorizes data in a searchable format. To learn how to create an Atlas Search index,
52+
see the :ref:`ruby-atlas-search-index` guide.
53+
54+
Search Your Data
55+
----------------
56+
57+
To use the ``$search`` aggregation pipeline stage, you must specify an Atlas Search query
58+
operator that indicates the type of query you want to run. You can optionally
59+
use a collector to specify the values and ranges of the query output. To view a
60+
table of all the operators and collectors available with Atlas Search, see the
61+
:atlas:`Operators and Collectors </atlas-search/operators-and-collectors>` page
62+
in the Atlas documentation.
63+
64+
The following example uses the ``compound`` operator to combine several operators into a
65+
single query. To learn more, see the :atlas:`Compound Operator
66+
</atlas-search/compound>` guide in the Atlas documentation.
67+
68+
The query has the following search criteria:
69+
70+
- The ``genres`` field must not contain ``Comedy``.
71+
- The ``title`` field must contain the string ``New York``.
72+
73+
The query also includes the following stages:
74+
75+
- :pipeline:`$limit`, to limit the output to 10 results.
76+
- :pipeline:`$project`, to exclude all fields except
77+
``title`` and add a field named ``score``.
78+
79+
.. io-code-block::
80+
:copyable: true
81+
82+
.. input::
83+
:language: ruby
84+
85+
pipeline = [
86+
{
87+
"$search" => {
88+
"index" => "index_name",
89+
"compound" => {
90+
"mustNot" => [
91+
{
92+
"text" => {
93+
"query" => ["Comedy"],
94+
"path" => "genres"
95+
}
96+
}
97+
],
98+
"must" => [
99+
{
100+
"text" => {
101+
"query" => ["New York"],
102+
"path" => "title"
103+
}
104+
}
105+
]
106+
}
107+
}
108+
},
109+
{ "$limit" => 10 },
110+
{
111+
"$project" => {
112+
"_id" => 0,
113+
"title" => 1,
114+
"score" => { "$meta" => "searchScore" }
115+
}
116+
}
117+
]
118+
119+
result = collection.aggregate(pipeline)
120+
puts result.to_a
121+
122+
.. output::
123+
:language: none
124+
:visible: false
125+
126+
{'title': 'New York, New York', 'score': 6.786379814147949}
127+
{'title': 'New York', 'score': 6.258603096008301}
128+
{'title': 'New York Doll', 'score': 5.381444931030273}
129+
{'title': 'Escape from New York', 'score': 4.719935417175293}
130+
{'title': 'Autumn in New York', 'score': 4.719935417175293}
131+
{'title': 'Sleepless in New York', 'score': 4.719935417175293}
132+
{'title': 'Gangs of New York', 'score': 4.719935417175293}
133+
{'title': 'Sherlock Holmes in New York', 'score': 4.203253746032715}
134+
{'title': 'New York: A Documentary Film', 'score': 4.203253746032715}
135+
{'title': 'An Englishman in New York', 'score': 4.203253746032715}
136+
137+
Additional Information
138+
----------------------
139+
140+
To learn more about the available Atlas Search operators, see the :atlas:`Operators and
141+
Collectors </atlas-search/operators-and-collectors>` guide in the MongoDB Atlas
142+
documentation.
143+
144+
For more information about Atlas Search, and to view more query examples, see the
145+
:atlas:`Atlas Search documentation </atlas-search>`.
146+
147+
If you'd like to perform vector searches on your data stored in Atlas, you must use Atlas
148+
Vector Search. To learn more about Atlas Vector Search, see the :atlas:`Atlas Vector
149+
Search documentation </atlas-vector-search/vector-search-overview/>`.

content/ruby-driver/current/source/common-errors.txt

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

content/ruby-driver/current/source/connect.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _ruby-connect:
2-
31
==================
42
Connect to MongoDB
53
==================
@@ -13,7 +11,7 @@ Connect to MongoDB
1311
.. facet::
1412
:name: genre
1513
:values: reference
16-
14+
1715
.. meta::
1816
:description: Learn how to use the Ruby driver to connect to MongoDB.
1917
:keywords: client, ssl
@@ -24,9 +22,7 @@ Connect to MongoDB
2422
:maxdepth: 1
2523

2624
Create a Client </connect/mongoclient>
27-
Stable API </connect/stable-api>
2825
Choose a Connection Target </connect/connection-targets>
2926
Connection Options </connect/connection-options>
30-
Configure TLS </connect/tls>
3127
Limit Server Execution Time </connect/csot>
3228
AWS Lambda <https://www.mongodb.com/docs/atlas/manage-connections-aws-lambda/>

0 commit comments

Comments
 (0)