Skip to content

Merge pull request #215 from shuangela/DOCSP-47835-clarify-batchsize #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ toc_landing_pages = [
"/reference/class/MongoDBModelCollectionInfo",
"/reference/class/MongoDBModelDatabaseInfo",
"/reference/class/MongoDBModelIndexInfo",
"/get-started",
"/connect",
"/read",
"/databases-collections",
Expand Down
10 changes: 5 additions & 5 deletions source/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ shown in the following code:
$pipeline = [
['<stage>' => <parameters>],
['<stage>' => <parameters>],
...
// ...
];

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

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

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

.. code-block:: php

$pipeline = [
$pipeline = new Pipeline(
Stage::<factory method>(
<stage specification>
),
Stage::<factory method>(
<stage specification>
),
...
];
// ...
);

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

Expand Down
6 changes: 3 additions & 3 deletions source/aggregation/atlas-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Search queries by using the Aggregation Builder:
To create a ``$search`` stage in your aggregation pipeline, perform the
following actions:

1. Create an array to store the pipeline stages.
1. Create a ``Pipeline`` instance to store the pipeline stages.

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

Expand All @@ -77,12 +77,12 @@ queries:

.. code-block:: php

$pipeline = [
$pipeline = new Pipeline(
Stage::search(
/* Atlas Search query specifications
Search::compound(...) */
),
];
);

Atlas Search Query Examples
---------------------------
Expand Down
6 changes: 3 additions & 3 deletions source/aggregation/vector-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Search queries by using the Aggregation Builder:
To create a ``$vectorSearch`` stage in your aggregation pipeline, perform the
following actions:

1. Create an array to store the pipeline stages.
1. Create a ``Pipeline`` instance to store the pipeline stages.

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

.. code-block:: php

$pipeline = [
$pipeline = new Pipeline(
Stage::vectorSearch(
/* Atlas Vector Search query specifications
index: '<index name>',
path: '<path to embeddings>', ...*/
),
];
);

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

Expand Down
12 changes: 6 additions & 6 deletions source/includes/aggregation/aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// end-array-explain

// start-builder-match-group
$pipeline = [
$pipeline = new MongoDB\Builder\Pipeline(
MongoDB\Builder\Stage::match(
date: [
MongoDB\Builder\Query::gte(new MongoDB\BSON\UTCDateTime(new DateTimeImmutable('2014-01-01'))),
Expand All @@ -63,7 +63,7 @@
MongoDB\Builder\Stage::sort(
totalSaleAmount: MongoDB\Builder\Type\Sort::Desc,
),
];
);

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

Expand All @@ -73,7 +73,7 @@
// end-builder-match-group

// start-builder-unwind
$pipeline = [
$pipeline = new MongoDB\Builder\Pipeline(
MongoDB\Builder\Stage::unwind(MongoDB\Builder\Expression::arrayFieldPath('items')),
MongoDB\Builder\Stage::unwind(MongoDB\Builder\Expression::arrayFieldPath('items.tags')),
MongoDB\Builder\Stage::group(
Expand All @@ -85,7 +85,7 @@
),
),
),
];
);

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

Expand All @@ -97,14 +97,14 @@
$collection = $client->db->orders;

// start-builder-lookup
$pipeline = [
$pipeline = new MongoDB\Builder\Pipeline(
MongoDB\Builder\Stage::lookup(
from: 'inventory',
localField: 'item',
foreignField: 'sku',
as: 'inventory_docs',
),
];
);

/* Performs the aggregation on the orders collection */
$cursor = $collection->aggregate($pipeline);
Expand Down
9 changes: 5 additions & 4 deletions source/includes/aggregation/atlas-search.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

// start-imports
use MongoDB\Builder\Pipeline;
use MongoDB\Builder\Search;
use MongoDB\Builder\Stage;
// end-imports
Expand Down Expand Up @@ -34,7 +35,7 @@
echo "\n";

// start-compound-search-query
$pipeline = [
$pipeline = new Pipeline(
Stage::search(
Search::compound(
must: [
Expand Down Expand Up @@ -63,7 +64,7 @@
name: 1
),
Stage::limit(3)
];
);

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

Expand Down Expand Up @@ -109,7 +110,7 @@
echo "\n";

// start-autocomplete-search-query
$pipeline = [
$pipeline = new Pipeline(
Stage::search(
Search::autocomplete(
query: 'Lucy',
Expand All @@ -118,7 +119,7 @@
),
Stage::limit(3),
Stage::project(_id: 0, name: 1),
];
);

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

Expand Down
9 changes: 5 additions & 4 deletions source/includes/aggregation/vector-search.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

// start-imports
use MongoDB\Builder\Pipeline;
use MongoDB\Builder\Stage;
// end-imports

Expand Down Expand Up @@ -42,7 +43,7 @@
echo "\n";

// start-basic-query
$pipeline = [
$pipeline = new Pipeline(
Stage::vectorSearch(
index: 'vector',
path: 'plot_embedding',
Expand All @@ -54,7 +55,7 @@
_id: 0,
title: 1,
),
];
);

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

Expand All @@ -64,7 +65,7 @@
// end-basic-query

// start-score-query
$pipeline = [
$pipeline = new Pipeline(
Stage::vectorSearch(
index: 'vector',
path: 'plot_embedding',
Expand All @@ -77,7 +78,7 @@
title: 1,
score: ['$meta' => 'vectorSearchScore'],
),
];
);

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

Expand Down
2 changes: 1 addition & 1 deletion source/includes/get-started/troubleshoot.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. note::

If you run into issues on this step, ask for help in the
If you run into issues in this tutorial, ask for help in the
:community-forum:`MongoDB Community Forums <tag/php/>`
or submit feedback by using the :guilabel:`Rate this page`
tab on the right or bottom right side of this page.
8 changes: 5 additions & 3 deletions source/read/cursor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ Retrieve All Documents
To retrieve all documents from a cursor, convert the cursor into an array by using
either of the following methods:

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

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

To learn more about the ``find()`` method, see the API documentation for
:phpmethod:`MongoDB\Collection::find()`.
:phpmethod:`MongoDB\Collection::find()`.
8 changes: 5 additions & 3 deletions source/reference/method/MongoDBCollection-aggregate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ Definition
.. code-block:: php

function aggregate(
array $pipeline,
array|Pipeline $pipeline,
array $options = []
): Traversable

Parameters
----------

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

``$options`` : array
An array specifying the desired options.
Expand Down Expand Up @@ -187,6 +188,7 @@ group, and sorts the results by name.
See Also
--------

- :ref:`php-aggregation`
- :phpmethod:`MongoDB\Database::aggregate()`
- :manual:`aggregate </reference/command/aggregate>` command reference in the
MongoDB manual
Expand Down
8 changes: 5 additions & 3 deletions source/reference/method/MongoDBDatabase-aggregate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ Definition
.. code-block:: php

function aggregate(
array $pipeline,
array|Pipeline $pipeline,
array $options = []
): Traversable

Parameters
----------

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

``$options`` : array
An array specifying the desired options.
Expand Down Expand Up @@ -170,6 +171,7 @@ running command operations.
See Also
--------

- :ref:`php-aggregation`
- :phpmethod:`MongoDB\Collection::aggregate()`
- :manual:`aggregate </reference/command/aggregate>` command reference in the
MongoDB manual
Expand Down
Loading