Skip to content

Commit 55bddf2

Browse files
authored
Merge branch 'v1.21' into DOCSP-45770-search-stage-args
2 parents 88b50a8 + 1543f93 commit 55bddf2

17 files changed

+261
-58
lines changed

source/includes/extracts-note.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ content: |
2020
---
2121
ref: note-atlas-search-async
2222
content: |
23-
Atlas Search indexes are managed asynchronously. After creating or updating an
23+
Atlas Search and Vector Search indexes are managed asynchronously. After creating or updating an
2424
index, you can periodically execute
2525
:phpmethod:`MongoDB\Collection::listSearchIndexes()` and check the
2626
``queryable`` :manual:`output field </reference/operator/aggregation/listSearchIndexes/#output>`

source/includes/indexes/indexes.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,48 @@
5757
// end-index-array-query
5858

5959
// start-create-search-index
60-
$indexName = $collection->createSearchIndex(
60+
$searchIndexName = $collection->createSearchIndex(
6161
['mappings' => ['dynamic' => true]],
6262
['name' => 'mySearchIdx']
6363
);
6464
// end-create-search-index
6565

66-
// start-create-search-indexes
66+
// start-create-vector-index
67+
$vectorSearchIndexName = $collection->createSearchIndex(
68+
[
69+
'fields' => [[
70+
'type' => 'vector',
71+
'path' => 'plot_embedding',
72+
'numDimensions' => 1536,
73+
'similarity' => 'dotProduct'
74+
]]
75+
],
76+
['name' => 'myVSidx', 'type' => 'vectorSearch']
77+
);
78+
// end-create-vector-index
79+
80+
// start-create-multiple-indexes
6781
$indexNames = $collection->createSearchIndexes(
6882
[
6983
[
70-
'name' => 'SearchIdx_dynamic',
84+
'name' => 'SearchIdx',
7185
'definition' => ['mappings' => ['dynamic' => true]],
7286
],
7387
[
74-
'name' => 'SearchIdx_simple',
88+
'name' => 'VSidx',
89+
'type' => 'vectorSearch',
7590
'definition' => [
76-
'mappings' => [
77-
'dynamic' => false,
78-
'fields' => [
79-
'title' => [
80-
'type' => 'string',
81-
'analyzer' => 'lucene.simple'
82-
]
83-
]
84-
]
91+
'fields' => [[
92+
'type' => 'vector',
93+
'path' => 'plot_embedding',
94+
'numDimensions' => 1536,
95+
'similarity' => 'dotProduct'
96+
]]
8597
],
8698
],
8799
]
88100
);
89-
// end-create-search-indexes
101+
// end-create-multiple-indexes
90102

91103
// start-list-search-indexes
92104
foreach ($collection->listSearchIndexes() as $indexInfo) {

source/indexes.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,10 @@ Atlas Search Index Management
229229
-----------------------------
230230

231231
The following sections contain code examples that describe how to manage
232-
:atlas:`Atlas Search indexes </atlas-search/manage-indexes/>`.
232+
:atlas:`Atlas Search </atlas-search/manage-indexes/>` and :atlas:`Vector
233+
Search </atlas-vector-search/vector-search-type/>` indexes.
233234

234-
.. note:: Atlas Search Index Management is Asynchronous
235+
.. note:: Atlas Search and Vector Search Index Management is Asynchronous
235236

236237
The {+php-library+} manages Atlas Search indexes asynchronously. The
237238
library methods described in the following sections return the server

source/indexes/atlas-search-index.txt

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,46 @@ Atlas Search Indexes
2020
Overview
2121
--------
2222

23-
The MongoDB Atlas Search feature enables you to perform full-text
24-
searches on collections hosted on Atlas. Before you can perform Atlas
25-
Search queries, you must create indexes that specify which
26-
fields to index and how they are indexed.
23+
In this guide, you can learn how to programmatically manage your Atlas
24+
Search and Atlas Vector Search indexes by using the {+library-short+}.
2725

28-
To learn more about Atlas Search, see the :atlas:`Atlas Search Overview
29-
</atlas-search/atlas-search-overview/>`.
26+
The Atlas Search feature enables you to perform full-text searches on
27+
collections hosted on MongoDB Atlas. To learn more about Atlas Search,
28+
see the :atlas:`Atlas Search Overview </atlas-search/atlas-search-overview/>`.
29+
30+
Atlas Vector Search enables you to perform semantic searches on vector
31+
embeddings stored in MongoDB Atlas. To learn more about Atlas Vector Search,
32+
see the :atlas:`Atlas Vector Search Overview </atlas-vector-search/vector-search-overview/>`.
3033

3134
You can use the following methods on a ``MongoDB\Collection`` instance
32-
to manage your Atlas Search indexes:
35+
to manage your Atlas Search and Vector Search indexes:
3336

3437
- ``MongoDB\Collection::createSearchIndex()``
3538
- ``MongoDB\Collection::createSearchIndexes()``
3639
- ``MongoDB\Collection::listSearchIndexes()``
3740
- ``MongoDB\Collection::updateSearchIndex()``
3841
- ``MongoDB\Collection::dropSearchIndex()``
3942

40-
.. note:: Atlas Search Index Management is Asynchronous
43+
.. note:: Atlas Search and Vector Search Index Management is Asynchronous
4144

42-
The {+php-library+} manages Atlas Search indexes asynchronously. The
43-
library methods described in the following sections return the server
44-
response immediately, but the changes to your Search indexes take
45-
place in the background and might not complete until some time later.
45+
The {+php-library+} manages Atlas Search and Vector Search indexes
46+
asynchronously. The library methods described in the following
47+
sections return the server response immediately, but the changes to
48+
your Search indexes take place in the background and might not
49+
complete until some time later.
4650

4751
The following sections provide code examples that demonstrate how to use
48-
each Atlas Search index management method.
52+
each of the preceding methods.
4953

5054
.. _php-atlas-search-index-create:
5155

5256
Create a Search Index
5357
---------------------
5458

5559
You can use the ``createSearchIndex()`` method to create a single Atlas
56-
Search index on a collection, or the ``createSearchIndexes()`` method to
57-
create multiple indexes simultaneously.
60+
Search or Vector Search index on a collection, or the
61+
``createSearchIndexes()`` method to create multiple indexes
62+
simultaneously.
5863

5964
The following code example shows how to create a single Atlas Search
6065
index:
@@ -64,25 +69,38 @@ index:
6469
:start-after: start-create-search-index
6570
:end-before: end-create-search-index
6671

67-
The following code example shows how to create multiple Atlas Search
68-
indexes:
72+
The following code example shows how to create a single Atlas Vector
73+
Search index:
74+
75+
.. literalinclude:: /includes/indexes/indexes.php
76+
:language: php
77+
:start-after: start-create-vector-index
78+
:end-before: end-create-vector-index
79+
80+
The following code example shows how to create Atlas Search and
81+
Vector Search indexes in one call:
6982

7083
.. literalinclude:: /includes/indexes/indexes.php
7184
:language: php
72-
:start-after: start-create-search-indexes
73-
:end-before: end-create-search-indexes
85+
:start-after: start-create-multiple-indexes
86+
:end-before: end-create-multiple-indexes
87+
88+
After you create Atlas Search or Atlas Vector Search indexes, you can
89+
perform the corresponding query types on your documents.
7490

75-
After you create a Search index, you can perform Atlas Search queries on
76-
your collection. To learn more, see :atlas:`Create and Run Atlas Search
77-
Queries </atlas-search/searching/>` in the Atlas documentation.
91+
..
92+
TODO uncomment when https://github.com/mongodb/docs-php-library/pull/197 is merged
93+
To learn more, see the following guides:
94+
- :ref:`php-atlas-search`
95+
- :ref:`php-vector-search`
7896

7997
.. _php-atlas-search-index-list:
8098

8199
List Search Indexes
82100
-------------------
83101

84102
You can use the ``listSearchIndexes()`` method to return an array of the
85-
Atlas Search indexes on a collection:
103+
Atlas Search and Vector Search indexes on a collection:
86104

87105
.. literalinclude:: /includes/indexes/indexes.php
88106
:language: php
@@ -96,9 +114,8 @@ Update a Search Index
96114
---------------------
97115

98116
You can use the ``updateSearchIndex()``
99-
method to update an Atlas Search index. You can use this method to
100-
change the name of a Search index or change the configuration of the
101-
index.
117+
method to update an Atlas Search or Vector Search index. You can use this method to
118+
change the name or configuration of an existing index.
102119

103120
The following code shows how to update a search index to use a simple
104121
analyzer on the ``title`` field:
@@ -115,7 +132,7 @@ Delete a Search Index
115132
---------------------
116133

117134
You can use the ``dropSearchIndex()`` method to remove an Atlas Search
118-
index from a collection.
135+
or Vector Search index from a collection.
119136

120137
The following code shows how to delete the Atlas Search index named
121138
``mySearchIdx``:

source/reference/class/MongoDBGridFSBucket.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Methods
3636

3737
__construct() </reference/method/MongoDBGridFSBucket__construct>
3838
delete() </reference/method/MongoDBGridFSBucket-delete>
39+
deleteByName() </reference/method/MongoDBGridFSBucket-deleteByName>
3940
downloadToStream() </reference/method/MongoDBGridFSBucket-downloadToStream>
4041
downloadToStreamByName() </reference/method/MongoDBGridFSBucket-downloadToStreamByName>
4142
drop() </reference/method/MongoDBGridFSBucket-drop>
@@ -57,10 +58,12 @@ Methods
5758
openUploadStream() </reference/method/MongoDBGridFSBucket-openUploadStream>
5859
registerGlobalStreamWrapperAlias() </reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias>
5960
rename() </reference/method/MongoDBGridFSBucket-rename>
61+
renameByName() </reference/method/MongoDBGridFSBucket-renameByName>
6062
uploadFromStream() </reference/method/MongoDBGridFSBucket-uploadFromStream>
6163

6264
- :phpmethod:`MongoDB\GridFS\Bucket::__construct()`
6365
- :phpmethod:`MongoDB\GridFS\Bucket::delete()`
66+
- :phpmethod:`MongoDB\GridFS\Bucket::deleteByName()`
6467
- :phpmethod:`MongoDB\GridFS\Bucket::downloadToStream()`
6568
- :phpmethod:`MongoDB\GridFS\Bucket::drop()`
6669
- :phpmethod:`MongoDB\GridFS\Bucket::find()`
@@ -81,4 +84,5 @@ Methods
8184
- :phpmethod:`MongoDB\GridFS\Bucket::openUploadStream()`
8285
- :phpmethod:`MongoDB\GridFS\Bucket::registerGlobalStreamWrapperAlias()`
8386
- :phpmethod:`MongoDB\GridFS\Bucket::rename()`
87+
- :phpmethod:`MongoDB\GridFS\Bucket::renameByName()`
8488
- :phpmethod:`MongoDB\GridFS\Bucket::uploadFromStream()`

source/reference/method/MongoDBClient__construct.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ Parameters
125125
'root' => 'MongoDB\Model\BSONDocument',
126126
]
127127

128+
* - builderEncoder
129+
- MongoDB\\Codec\\Encoder
130+
- Encoder to use for query and aggregation builders. If not set, this option
131+
defaults to a new instance of the ``MongoDB\Builder\BuilderEncoder`` class.
132+
133+
.. versionadded:: 1.21
134+
128135
* - allow_invalid_hostname
129136
- boolean
130137
- Disables hostname validation if ``true``. Defaults to ``false``.

source/reference/method/MongoDBCollection-bulkWrite.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ Parameters
6565
- Type
6666
- Description
6767

68+
* - builderEncoder
69+
- MongoDB\\Codec\\Encoder
70+
- Encoder to use for query and aggregation builders. If not set, this option
71+
defaults to a new instance of the ``MongoDB\Builder\BuilderEncoder`` class.
72+
73+
.. versionadded:: 1.21
74+
6875
* - bypassDocumentValidation
6976
- boolean
7077
- If ``true``, allows the write operation to circumvent document level

source/reference/method/MongoDBCollection-createIndexes.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
MongoDB\\Collection::createIndexes()
33
====================================
44

5-
.. default-domain:: mongodb
6-
75
.. contents:: On this page
86
:local:
97
:backlinks: none

source/reference/method/MongoDBCollection-createSearchIndex.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ MongoDB\\Collection::createSearchIndex()
44

55
.. versionadded:: 1.17
66

7-
.. default-domain:: mongodb
8-
97
.. contents:: On this page
108
:local:
119
:backlinks: none
@@ -17,7 +15,7 @@ Definition
1715

1816
.. phpmethod:: MongoDB\Collection::createSearchIndex()
1917

20-
Create an Atlas Search index for the collection.
18+
Create an Atlas Search or Vector Search index for the collection.
2119

2220
.. code-block:: php
2321

@@ -52,15 +50,21 @@ Parameters
5250

5351
* - name
5452
- string
55-
- Name of the search index to create.
53+
- | Name of the search index to create.
54+
| You cannot create multiple indexes with the same name on a single
55+
collection. If you do not specify a name, the default index
56+
name is ``default``.
5657

57-
You cannot create multiple indexes with the same name on a single
58-
collection. If you do not specify a name, the index is named "default".
58+
* - type
59+
- string
60+
- Type of index to create. Accepted values are ``'search'`` and
61+
``'vectorSearch'``. If you omit this option, the default
62+
value is ``'search'`` and the method creates an Atlas Search index.
5963

6064
Return Values
6165
-------------
6266

63-
The name of the created Atlas Search index as a string.
67+
The name of the created Atlas Search or Vector Search index as a string.
6468

6569
Errors/Exceptions
6670
-----------------
@@ -111,6 +115,7 @@ See Also
111115
- :phpmethod:`MongoDB\Collection::dropSearchIndex()`
112116
- :phpmethod:`MongoDB\Collection::listSearchIndexes()`
113117
- :phpmethod:`MongoDB\Collection::updateSearchIndex()`
118+
- :ref:`php-atlas-search-index` guide
114119
- :manual:`createSearchIndexes </reference/command/createSearchIndexes>` command
115120
reference in the MongoDB manual
116121
- `Atlas Search <https://www.mongodb.com/docs/atlas/atlas-search/>`__ documentation in the MongoDB Manual

source/reference/method/MongoDBCollection-createSearchIndexes.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Definition
1717

1818
.. phpmethod:: MongoDB\Collection::createSearchIndexes()
1919

20-
Create one or more Atlas Search indexes for the collection.
20+
Create one or more Atlas Search or Vector Search indexes for the collection.
2121

2222
.. code-block:: php
2323

@@ -40,7 +40,12 @@ Parameters
4040

4141
An optional ``name`` string field specifies the name of the search index to
4242
create. You cannot create multiple indexes with the same name on a single
43-
collection. If you do not specify a name, the index is named "default".
43+
collection. If you do not specify a name, the default index name is
44+
``default``.
45+
46+
An optional ``type`` string field specifies the type of search index to
47+
create. Accepted values are ``'search'`` and ``'vectorSearch'``. If
48+
you do not specify a type, the method creates an Atlas Search index.
4449

4550
``$options`` : array
4651
An array specifying the desired options.
@@ -60,7 +65,8 @@ Parameters
6065
Return Values
6166
-------------
6267

63-
The names of the created Atlas Search indexes as an array of strings.
68+
The names of the created Atlas Search and Vector Search indexes as an
69+
array of strings.
6470

6571
Errors/Exceptions
6672
-----------------
@@ -118,6 +124,7 @@ See Also
118124
- :phpmethod:`MongoDB\Collection::dropSearchIndex()`
119125
- :phpmethod:`MongoDB\Collection::listSearchIndexes()`
120126
- :phpmethod:`MongoDB\Collection::updateSearchIndex()`
127+
- :ref:`php-atlas-search-index` guide
121128
- :manual:`createSearchIndexes </reference/command/createSearchIndexes>` command
122129
reference in the MongoDB manual
123130
- `Atlas Search <https://www.mongodb.com/docs/atlas/atlas-search/>`__ documentation in the MongoDB Manual

source/reference/method/MongoDBCollection__construct.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ Definition
4949
- Type
5050
- Description
5151

52+
* - builderEncoder
53+
- MongoDB\\Codec\\Encoder
54+
- Encoder to use for query and aggregation builders. If not set, this option
55+
defaults to a new instance of the ``MongoDB\Builder\BuilderEncoder`` class.
56+
57+
.. versionadded:: 1.21
58+
5259
* - codec
5360
- MongoDB\\Codec\\DocumentCodec
5461
- The default :doc:`codec </data-formats/codecs>` to use for collection

source/reference/method/MongoDBDatabase-createCollection.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ Parameters
152152
:manual:`db.createCollection()
153153
</reference/method/db.createCollection>` for more information.
154154

155+
*Deprecated*: This option is deprecated and will be removed in
156+
the v2.0 {+library-short+} release. To learn more about upgrading
157+
from the MMAPv1 storage engine to Wired Tiger, see the
158+
:manual:`Change a Self-Managed Standalone to WiredTiger </tutorial/change-standalone-wiredtiger/>`
159+
guide in the Server manual.
160+
155161
* - indexOptionDefaults
156162
- array|object
157163
- Allows users to specify a default configuration for indexes when

0 commit comments

Comments
 (0)