Skip to content

Commit 5c64168

Browse files
authored
Prep for 2.19.3 (#2807)
* version bump * add docs for the Atlas search index management API (#2806) * nokogiri requires zlib * async-io 1.37.0 (newly released) breaks on Ruby 2.5, 2.6 this is a dependency of the rubydns gem
1 parent a0526f8 commit 5c64168

File tree

6 files changed

+136
-3
lines changed

6 files changed

+136
-3
lines changed

docs/reference/schema-operations.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ including managing databases, collections, indexes and users.
1515
/reference/database-tasks
1616
/reference/collection-tasks
1717
/reference/indexing
18+
/reference/search-indexes
1819
/reference/collations

docs/reference/search-indexes.txt

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
********************
2+
Atlas Search Indexes
3+
********************
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
If you are using a database hosted by MongoDB Atlas, the driver provides the
14+
ability to create, drop and view `Atlas search indexes <https://www.mongodb.com/docs/atlas/atlas-search/>`_
15+
on a collection through the ``search_indexes`` attribute:
16+
17+
.. code-block:: ruby
18+
19+
client = Mongo::Client.new(your_atlas_uri, database: 'music')
20+
client[:bands].search_indexes
21+
# => #<Mongo::SearchIndex::View:0x000055e2822b9318 @collection=#<Mongo::Collection:0x660 namespace=music.bands> ...>
22+
23+
24+
Creating Search Indexes
25+
=======================
26+
27+
Search indexes can be created one at a time, or several can be created in
28+
parallel in a single operation.
29+
30+
To create a single index, use ``search_indexes#create_one``, passing the index
31+
definition as the first argument, and an optional name for the index as the
32+
second argument.
33+
34+
.. code-block:: ruby
35+
36+
client[:bands].search_indexes.create_one({ dynamic: true })
37+
38+
client[:bands].search_indexes.create_one(
39+
{
40+
dynamic: false,
41+
fields: {
42+
name: { type: 'string', analyzer: 'lucene.simple' }
43+
}
44+
},
45+
'band-name-index'
46+
)
47+
48+
To create multiple indexes, use ``search_indexes#create_many`` which accepts
49+
an array of index specifications. Unlike ``create_one``, each index
50+
specification is a hash with at least a ``definition`` key, which
51+
defines the index. Each has may also specify a ``name`` key, to name
52+
the index.
53+
54+
.. code-block:: ruby
55+
56+
client[:bands].search_indexes.create_many([
57+
{ definition: { dynamic: true } },
58+
{ name: 'band-name-index,
59+
definition: {
60+
dynamic: false,
61+
fields: {
62+
name: { type: 'string', analyzer: 'lucene.simple' }
63+
}
64+
}
65+
},
66+
])
67+
68+
Note that whether you call ``create_one`` or ``create_many``, the
69+
method will return immediately, before the indexes are created. The
70+
indexes are then created in the background, asynchronously.
71+
72+
73+
Update Search Indexes
74+
=====================
75+
76+
You can programmatically update an Atlas search index. For example, you
77+
might do this to change the analyzer used, or to provide an explicit field
78+
mapping, instead of a dynamic one. To do this, use the ``search_indexes#update_one``
79+
method:
80+
81+
.. code-block:: ruby
82+
83+
client[:bands].search_indexes.update_one(new_definition, id: index_id)
84+
85+
client[:bands].search_indexes.update_one(new_definition, name: index_name)
86+
87+
Indexes may be identified by either id, or name, but you must specify one
88+
or the other. The new index definition must be a complete definition--it will
89+
take precedence as specified over the existing definition.
90+
91+
To get the id or name of an index that you wish to update, you can
92+
`list the search indexes <#listing-search-indexes>`_.
93+
94+
95+
Dropping Search Indexes
96+
=======================
97+
98+
To drop Atlas search indexes, call ``search_indexes#drop_one`` and
99+
provide either the ``id`` or the ``name`` of the index you wish to
100+
drop.
101+
102+
.. code-block:: ruby
103+
104+
client[:bands].search_indexes.drop_one(id: index_id)
105+
106+
client[:bands].search_indexes.drop_one(name: index_name)
107+
108+
In either case, the method will return immediately and the index will
109+
be dropped in the background, asynchronously.
110+
111+
To get the id or name of an index that you wish to drop, you can
112+
`list the search indexes <#listing-search-indexes>`_.
113+
114+
115+
Listing Search Indexes
116+
======================
117+
118+
To list the available search indexes, iterate over the
119+
``search_indexes`` object:
120+
121+
.. code-block:: ruby
122+
123+
client[:bands].search_indexes.each do |index_spec|
124+
p index_spec['id']
125+
p index_spec['name']
126+
p index_spec['status']
127+
p index_spec['queryable']
128+
p index_spec['latestDefinition']
129+
end

docs/release-notes.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ This release includes the following new features:
4242
when Azure Key Vault is used for client side encryption.
4343
- `Queryable Encryption <https://www.mongodb.com/docs/upcoming/core/queryable-encryption/queryable-encryption/>`_ support is extended.
4444
- Added support for Queryable Encryption Range Indexes.
45-
- A `crypt_shared <https://www.mongodb.com/docs/manual/core/queryable-encryption/reference/shared-library/#download-the-automatic-encryption-shared-library>`_
45+
- A `crypt_shared <https://www.mongodb.com/docs/manual/core/queryable-encryption/reference/shared-library/#download-the-automatic-encryption-shared-library>`_
4646
library can be now used instead of ``mongocryptd``.
4747
- Added support for AWS IAM Roles for service accounts, EKS in particular.
4848
- AWS Credentials are now cached when possible.
49+
- Added support for creating and managing `Atlas search indexes <https://www.mongodb.com/docs/atlas/atlas-search/>`_ via the
50+
Ruby driver.
4951

5052
.. _release-notes-2.18:
5153

gemfiles/standard.rb

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def standard_dependencies
4949
group :testing do
5050
gem 'timecop'
5151
gem 'ice_nine'
52+
gem 'async-io', '~> 1.36.0' # 1.37.0 introduced a regression that breaks on Ruby 2.5, 2.6
5253
gem 'rubydns', platforms: :mri
5354
gem 'rspec-retry'
5455
gem 'rfc', '~> 0.2.0'

lib/mongo/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ module Mongo
2020
# The current version of the driver.
2121
#
2222
# @since 2.0.0
23-
VERSION = '2.19.2'.freeze
23+
VERSION = '2.19.3'.freeze
2424
end

release/mri/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM debian:10
33
ENV DEBIAN_FRONTEND=noninteractive
44

55
RUN apt-get update && \
6-
apt-get -y install git ruby-bundler make gcc ruby-dev
6+
apt-get -y install zlib1g-dev git ruby-bundler make gcc ruby-dev
77

88
WORKDIR /app
99

0 commit comments

Comments
 (0)