Skip to content

Commit a18ad37

Browse files
committed
add api section, edit atlas search examples
1 parent a6c714d commit a18ad37

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

source/includes/indexes/index-code-examples.rb

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,37 @@
3636

3737
# Create Search Index
3838
# start-create-search-index
39-
index_definition = {
40-
name: '<index name>',
41-
definition: {
42-
mappings: {
43-
dynamic: false,
44-
fields: { <field name>: {type: '<field type>'} }
39+
index_definition = {
40+
mappings: {
41+
dynamic: false,
42+
fields: {
43+
<field name>: {type: '<field type>'}
4544
}
4645
}
4746
}
48-
collection.database.command(
49-
createSearchIndexes: '<collection name>',
50-
indexes: [index_definition]
51-
)
47+
collection.search_indexes.create_one(index_definition, name: '<index name>')
5248
# end-create-search-index
5349

5450
# List Search Indexes
5551
# start-list-search-indexes
56-
collection.database.command(listSearchIndexes: '<collection name>')
52+
puts collection.search_indexes.collect(&:to_json)
5753
# end-list-search-indexes
5854

5955
# Update Search Indexes
6056
#start-update-search-indexes
6157
updated_definition = {
6258
mappings: {
6359
dynamic: false,
64-
fields: { <updated field name>: { type: '<field type>' } }
60+
fields: { <updated field name>: { type: '<updated field type>' } }
6561
}
6662
}
67-
collection.database.command(
68-
updateSearchIndex: '<collection name>',
69-
name: '<index name>',
70-
definition: updated_definition
71-
)
63+
64+
collection.search_indexes.update_one(updated_definition, name: '<index name>')
7265
#end-update-search-indexes
7366

7467
# Delete Search Index
7568
# start-drop-search-index
76-
collection.database.command(
77-
dropSearchIndex: '<collection name>',
78-
name: '<index name>'
79-
)
69+
collection.search_indexes.drop_one(name: '<index name>')
8070
# end-drop-search-index
8171

8272
# Text Index

source/indexes.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,14 @@ when creating indexes. These options mirror the options supported by the
293293
For more information, see :manual:`commitQuorom
294294
</reference/method/db.collection.createIndex/#std-label-createIndex-method-commitQuorum>`
295295
in the {+mdb-server+} manual.
296+
297+
API Documentation
298+
-----------------
299+
300+
To learn more about the methods or objects used in this guide, see the following
301+
API documentation:
302+
303+
- `indexes <{+api-root+}/Mongo/Collection.html#indexes-instance_method>`__
304+
- `create_one <{+api-root+}/Mongo/Index/View.html#create_one-instance_method>`__
305+
- `drop_one <{+api-root+}/Mongo/Index/View.html#drop_one-instance_method>`__
306+
- `drop_all <{+api-root+}/Mongo/Index/View.html#drop_all-instance_method>`__

source/indexes/single-field-index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,5 @@ To learn more about any of the methods discussed in this guide, see the
131131
following API documentation:
132132

133133
- `indexes <{+api-root+}/Mongo/Collection.html#indexes-instance_method>`__
134-
- `create_one <{+api-root+}/Mongo/Index/View.html>`__
134+
- `create_one <{+api-root+}/Mongo/Index/View.html#create_one-instance_method>`__
135135
- `find <{+api-root+}/Mongo/Collection.html#find-instance_method>`__

0 commit comments

Comments
 (0)