Skip to content

Commit e056074

Browse files
committed
Merge pull request #215 from shuangela/DOCSP-47835-clarify-batchsize
DOCSP-47835 Clarify batchsize behavior
1 parent 82a1ac7 commit e056074

11 files changed

+43
-36
lines changed

snooty.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ toc_landing_pages = [
2121
"/reference/class/MongoDBModelCollectionInfo",
2222
"/reference/class/MongoDBModelDatabaseInfo",
2323
"/reference/class/MongoDBModelIndexInfo",
24-
"/get-started",
2524
"/connect",
2625
"/read",
2726
"/databases-collections",

source/aggregation.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ shown in the following code:
111111
$pipeline = [
112112
['<stage>' => <parameters>],
113113
['<stage>' => <parameters>],
114-
...
114+
// ...
115115
];
116116

117117
$cursor = $collection->aggregate($pipeline);
@@ -196,7 +196,7 @@ Aggregation Builder
196196
To create an aggregation pipeline by using the Aggregation Builder,
197197
perform the following actions:
198198

199-
1. Create an array to store the pipeline stages.
199+
1. Create a ``MongoDB\Builder\Pipeline`` instance to store the pipeline stages.
200200

201201
#. For each stage, call the a factory method from the
202202
``Stage`` that shares the same name as your desired aggregation
@@ -212,15 +212,15 @@ aggregation pipelines:
212212

213213
.. code-block:: php
214214

215-
$pipeline = [
215+
$pipeline = new Pipeline(
216216
Stage::<factory method>(
217217
<stage specification>
218218
),
219219
Stage::<factory method>(
220220
<stage specification>
221221
),
222-
...
223-
];
222+
// ...
223+
);
224224

225225
$cursor = $collection->aggregate($pipeline);
226226

source/aggregation/atlas-search.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Search queries by using the Aggregation Builder:
6565
To create a ``$search`` stage in your aggregation pipeline, perform the
6666
following actions:
6767

68-
1. Create an array to store the pipeline stages.
68+
1. Create a ``Pipeline`` instance to store the pipeline stages.
6969

7070
#. Call the ``Stage::search()`` method to create the Atlas Search stage.
7171

@@ -77,12 +77,12 @@ queries:
7777

7878
.. code-block:: php
7979

80-
$pipeline = [
80+
$pipeline = new Pipeline(
8181
Stage::search(
8282
/* Atlas Search query specifications
8383
Search::compound(...) */
8484
),
85-
];
85+
);
8686

8787
Atlas Search Query Examples
8888
---------------------------

source/aggregation/vector-search.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Search queries by using the Aggregation Builder:
6666
To create a ``$vectorSearch`` stage in your aggregation pipeline, perform the
6767
following actions:
6868

69-
1. Create an array to store the pipeline stages.
69+
1. Create a ``Pipeline`` instance to store the pipeline stages.
7070

7171
#. Call the ``Stage::vectorSearch()`` method to create the Atlas Vector
7272
Search stage.
@@ -79,13 +79,13 @@ queries:
7979

8080
.. code-block:: php
8181

82-
$pipeline = [
82+
$pipeline = new Pipeline(
8383
Stage::vectorSearch(
8484
/* Atlas Vector Search query specifications
8585
index: '<index name>',
8686
path: '<path to embeddings>', ...*/
8787
),
88-
];
88+
);
8989

9090
You must pass the following parameters to the ``vectorSearch()`` method:
9191

source/includes/aggregation/aggregation.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
// end-array-explain
4141

4242
// start-builder-match-group
43-
$pipeline = [
43+
$pipeline = new MongoDB\Builder\Pipeline(
4444
MongoDB\Builder\Stage::match(
4545
date: [
4646
MongoDB\Builder\Query::gte(new MongoDB\BSON\UTCDateTime(new DateTimeImmutable('2014-01-01'))),
@@ -63,7 +63,7 @@
6363
MongoDB\Builder\Stage::sort(
6464
totalSaleAmount: MongoDB\Builder\Type\Sort::Desc,
6565
),
66-
];
66+
);
6767

6868
$cursor = $collection->aggregate($pipeline);
6969

@@ -73,7 +73,7 @@
7373
// end-builder-match-group
7474

7575
// start-builder-unwind
76-
$pipeline = [
76+
$pipeline = new MongoDB\Builder\Pipeline(
7777
MongoDB\Builder\Stage::unwind(MongoDB\Builder\Expression::arrayFieldPath('items')),
7878
MongoDB\Builder\Stage::unwind(MongoDB\Builder\Expression::arrayFieldPath('items.tags')),
7979
MongoDB\Builder\Stage::group(
@@ -85,7 +85,7 @@
8585
),
8686
),
8787
),
88-
];
88+
);
8989

9090
$cursor = $collection->aggregate($pipeline);
9191

@@ -97,14 +97,14 @@
9797
$collection = $client->db->orders;
9898

9999
// start-builder-lookup
100-
$pipeline = [
100+
$pipeline = new MongoDB\Builder\Pipeline(
101101
MongoDB\Builder\Stage::lookup(
102102
from: 'inventory',
103103
localField: 'item',
104104
foreignField: 'sku',
105105
as: 'inventory_docs',
106106
),
107-
];
107+
);
108108

109109
/* Performs the aggregation on the orders collection */
110110
$cursor = $collection->aggregate($pipeline);

source/includes/aggregation/atlas-search.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
// start-imports
4+
use MongoDB\Builder\Pipeline;
45
use MongoDB\Builder\Search;
56
use MongoDB\Builder\Stage;
67
// end-imports
@@ -34,7 +35,7 @@
3435
echo "\n";
3536

3637
// start-compound-search-query
37-
$pipeline = [
38+
$pipeline = new Pipeline(
3839
Stage::search(
3940
Search::compound(
4041
must: [
@@ -63,7 +64,7 @@
6364
name: 1
6465
),
6566
Stage::limit(3)
66-
];
67+
);
6768

6869
$cursor = $collection->aggregate($pipeline);
6970

@@ -109,7 +110,7 @@
109110
echo "\n";
110111

111112
// start-autocomplete-search-query
112-
$pipeline = [
113+
$pipeline = new Pipeline(
113114
Stage::search(
114115
Search::autocomplete(
115116
query: 'Lucy',
@@ -118,7 +119,7 @@
118119
),
119120
Stage::limit(3),
120121
Stage::project(_id: 0, name: 1),
121-
];
122+
);
122123

123124
$cursor = $collection->aggregate($pipeline);
124125

source/includes/aggregation/vector-search.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
// start-imports
4+
use MongoDB\Builder\Pipeline;
45
use MongoDB\Builder\Stage;
56
// end-imports
67

@@ -42,7 +43,7 @@
4243
echo "\n";
4344

4445
// start-basic-query
45-
$pipeline = [
46+
$pipeline = new Pipeline(
4647
Stage::vectorSearch(
4748
index: 'vector',
4849
path: 'plot_embedding',
@@ -54,7 +55,7 @@
5455
_id: 0,
5556
title: 1,
5657
),
57-
];
58+
);
5859

5960
$cursor = $collection->aggregate($pipeline);
6061

@@ -64,7 +65,7 @@
6465
// end-basic-query
6566

6667
// start-score-query
67-
$pipeline = [
68+
$pipeline = new Pipeline(
6869
Stage::vectorSearch(
6970
index: 'vector',
7071
path: 'plot_embedding',
@@ -77,7 +78,7 @@
7778
title: 1,
7879
score: ['$meta' => 'vectorSearchScore'],
7980
),
80-
];
81+
);
8182

8283
$cursor = $collection->aggregate($pipeline);
8384

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. note::
22

3-
If you run into issues on this step, ask for help in the
3+
If you run into issues in this tutorial, ask for help in the
44
:community-forum:`MongoDB Community Forums <tag/php/>`
55
or submit feedback by using the :guilabel:`Rate this page`
66
tab on the right or bottom right side of this page.

source/read/cursor.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ Retrieve All Documents
115115
To retrieve all documents from a cursor, convert the cursor into an array by using
116116
either of the following methods:
117117

118-
- ``MongoDB\\Driver\\Cursor::toArray()``: Call on a ``MongoDB\Driver\Cursor`` object
119-
- ``iterator_to_array()``: Pass a ``MongoDB\Driver\Cursor`` object as a parameter
118+
- :php:`MongoDB\Driver\Cursor::toArray() <mongodb-driver-cursor.toarray>`: Call
119+
on a ``MongoDB\Driver\Cursor`` object
120+
- :php:`iterator_to_array() <function.iterator-to-array>`: Pass a
121+
``MongoDB\Driver\Cursor`` object as a parameter
120122

121123
The following example calls the ``toArray()`` method on a cursor to store its results
122124
in an array:
@@ -187,4 +189,4 @@ API Documentation
187189
~~~~~~~~~~~~~~~~~
188190

189191
To learn more about the ``find()`` method, see the API documentation for
190-
:phpmethod:`MongoDB\Collection::find()`.
192+
:phpmethod:`MongoDB\Collection::find()`.

source/reference/method/MongoDBCollection-aggregate.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ Definition
2121
.. code-block:: php
2222

2323
function aggregate(
24-
array $pipeline,
24+
array|Pipeline $pipeline,
2525
array $options = []
2626
): Traversable
2727

2828
Parameters
2929
----------
3030

31-
``$pipeline`` : array
31+
``$pipeline`` : array|Pipeline
3232
Specifies an :manual:`aggregation pipeline </core/aggregation-pipeline>`
33-
operation.
33+
operation. You can include aggregation stages in a
34+
``MongoDB\Builder\Pipeline`` instance or in an array.
3435

3536
``$options`` : array
3637
An array specifying the desired options.
@@ -187,6 +188,7 @@ group, and sorts the results by name.
187188
See Also
188189
--------
189190

191+
- :ref:`php-aggregation`
190192
- :phpmethod:`MongoDB\Database::aggregate()`
191193
- :manual:`aggregate </reference/command/aggregate>` command reference in the
192194
MongoDB manual

source/reference/method/MongoDBDatabase-aggregate.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ Definition
2525
.. code-block:: php
2626

2727
function aggregate(
28-
array $pipeline,
28+
array|Pipeline $pipeline,
2929
array $options = []
3030
): Traversable
3131

3232
Parameters
3333
----------
3434

35-
``$pipeline`` : array
35+
``$pipeline`` : array|Pipeline
3636
Specifies an :manual:`aggregation pipeline </core/aggregation-pipeline>`
37-
operation.
37+
operation. You can include aggregation stages in a
38+
``MongoDB\Builder\Pipeline`` instance or in an array.
3839

3940
``$options`` : array
4041
An array specifying the desired options.
@@ -170,6 +171,7 @@ running command operations.
170171
See Also
171172
--------
172173

174+
- :ref:`php-aggregation`
173175
- :phpmethod:`MongoDB\Collection::aggregate()`
174176
- :manual:`aggregate </reference/command/aggregate>` command reference in the
175177
MongoDB manual

0 commit comments

Comments
 (0)