Skip to content

Commit bcd9a2e

Browse files
committed
DOCSP-46398 Fix Atlas Search Create Ex (#144)
* DOCSP-46398 Fix Atlas Search Create Ex * edit * formatting * format * RR change field name (cherry picked from commit 64503a4)
1 parent 8741675 commit bcd9a2e

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

source/reference/search-indexes.txt

+22-17
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@ second argument.
3333

3434
.. code-block:: ruby
3535

36-
client[:bands].search_indexes.create_one({ dynamic: true })
37-
36+
# Creates indexes on all dynamically indexable fields with a default index name
3837
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'
38+
{ mappings: { dynamic: true } }
4639
)
4740

41+
# Creates an index on the specified field with the specified index name
42+
index_definition = {
43+
mappings: {
44+
dynamic: false,
45+
fields: {
46+
country: { type: 'string', analyzer: 'lucene.simple' }
47+
}
48+
}
49+
}
50+
client[:bands].search_indexes.create_one(index_definition, name: 'band-name-index')
51+
4852
To create multiple indexes, use ``search_indexes#create_many`` which accepts
4953
an array of index specifications. Unlike ``create_one``, each index
5054
specification is a hash with at least a ``definition`` key, which
@@ -53,23 +57,24 @@ the index.
5357

5458
.. code-block:: ruby
5559

56-
client[:bands].search_indexes.create_many([
57-
{ definition: { dynamic: true } },
58-
{ name: 'band-name-index,
59-
definition: {
60+
index_spec_1 = { definition: { mappings: { dynamic: true } } }
61+
index_spec_2 = {
62+
name: 'band-name-index',
63+
definition: {
64+
mappings: {
6065
dynamic: false,
6166
fields: {
62-
name: { type: 'string', analyzer: 'lucene.simple' }
67+
country: { type: 'string', analyzer: 'lucene.simple' }
6368
}
6469
}
65-
},
66-
])
70+
}
71+
}
72+
client[:bands].search_indexes.create_many([index_spec_1, index_spec_2])
6773

6874
Note that whether you call ``create_one`` or ``create_many``, the
6975
method will return immediately, before the indexes are created. The
7076
indexes are then created in the background, asynchronously.
7177

72-
7378
Update Search Indexes
7479
=====================
7580

0 commit comments

Comments
 (0)