Skip to content

Commit 491f26a

Browse files
committed
indentation fix
1 parent 9d4aae2 commit 491f26a

File tree

2 files changed

+134
-134
lines changed

2 files changed

+134
-134
lines changed

source/aggregation/vector-search.txt

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ perform Atlas Vector Search queries by using the :ref:`Aggregation Builder API
2727

2828
.. note:: Deployment Compatibility
2929

30-
You can use the Atlas Search feature only when
31-
you connect to MongoDB Atlas clusters. This feature is not
32-
available for self-managed deployments.
30+
You can use the Atlas Search feature only when
31+
you connect to MongoDB Atlas clusters. This feature is not
32+
available for self-managed deployments.
3333

3434
To learn more about Atlas Vector Search, see the :atlas:`Overview
3535
</atlas-vector-search/vector-search-overview/>` in the
@@ -82,11 +82,11 @@ queries:
8282
.. code-block:: php
8383

8484
$pipeline = new Pipeline(
85-
Stage::vectorSearch(
86-
/* Atlas Vector Search query specifications
87-
index: '<index name>',
88-
path: '<path to embeddings>', ...*/
89-
),
85+
Stage::vectorSearch(
86+
/* Atlas Vector Search query specifications
87+
index: '<index name>',
88+
path: '<path to embeddings>', ...*/
89+
),
9090
);
9191

9292
You must pass the following parameters to the ``vectorSearch()`` method:
@@ -95,24 +95,24 @@ You must pass the following parameters to the ``vectorSearch()`` method:
9595
:header-rows: 1
9696

9797
* - Parameter
98-
- Type
99-
- Description
98+
- Type
99+
- Description
100100

101101
* - ``index``
102-
- ``string``
103-
- Name of the vector search index
102+
- ``string``
103+
- Name of the vector search index
104104

105105
* - ``path``
106-
- ``array`` or ``string``
107-
- Field that stores vector embeddings
106+
- ``array`` or ``string``
107+
- Field that stores vector embeddings
108108

109109
* - ``queryVector``
110-
- ``array``
111-
- Vector representation of your query
110+
- ``array``
111+
- Vector representation of your query
112112

113113
* - ``limit``
114-
- ``int``
115-
- Number of results to return
114+
- ``int``
115+
- Number of results to return
116116

117117
Atlas Search Query Examples
118118
---------------------------
@@ -123,7 +123,7 @@ section use sample data from the ``sample_mflix.embedded_movies``
123123
collection.
124124

125125
.. note:: Query Vector Length
126-
126+
127127
For demonstrative purposes, the examples in this section use
128128
sample query vectors that contain very few elements, compared to
129129
the query vector you might use in a runnable application. To view an
@@ -142,19 +142,19 @@ The following code performs an Atlas Vector Search query on the
142142
:copyable: true
143143

144144
.. input:: /includes/aggregation/vector-search.php
145-
:language: php
146-
:dedent:
147-
:start-after: start-basic-query
148-
:end-before: end-basic-query
145+
:language: php
146+
:dedent:
147+
:start-after: start-basic-query
148+
:end-before: end-basic-query
149149

150150
.. output::
151-
:language: json
152-
:visible: false
151+
:language: json
152+
:visible: false
153153

154-
{"title":"Thrill Seekers"}
155-
{"title":"About Time"}
156-
{"title":"Timecop"}
157-
// Results truncated
154+
{"title":"Thrill Seekers"}
155+
{"title":"About Time"}
156+
{"title":"Timecop"}
157+
// Results truncated
158158

159159
Vector Search Score
160160
~~~~~~~~~~~~~~~~~~~
@@ -167,19 +167,19 @@ field, which describes how well the document matches the query vector:
167167
:copyable: true
168168

169169
.. input:: /includes/aggregation/vector-search.php
170-
:language: php
171-
:dedent:
172-
:start-after: start-score-query
173-
:end-before: end-score-query
170+
:language: php
171+
:dedent:
172+
:start-after: start-score-query
173+
:end-before: end-score-query
174174

175175
.. output::
176-
:language: json
177-
:visible: false
176+
:language: json
177+
:visible: false
178178

179-
{"title":"Thrill Seekers","score":0.927734375}
180-
{"title":"About Time","score":0.925750732421875}
181-
{"title":"Timecop","score":0.9241180419921875}
182-
// Results truncated
179+
{"title":"Thrill Seekers","score":0.927734375}
180+
{"title":"About Time","score":0.925750732421875}
181+
{"title":"Timecop","score":0.9241180419921875}
182+
// Results truncated
183183

184184
Vector Search Options
185185
~~~~~~~~~~~~~~~~~~~~~
@@ -192,26 +192,26 @@ following optional parameters to ``vectorSearch()``:
192192
:header-rows: 1
193193

194194
* - Optional Parameter
195-
- Type
196-
- Description
197-
- Default Value
195+
- Type
196+
- Description
197+
- Default Value
198198

199199
* - ``exact``
200-
- ``bool``
201-
- Specifies whether to run an Exact Nearest Neighbor (``true``) or
202-
Approximate Nearest Neighbor (``false``) search
203-
- ``false``
200+
- ``bool``
201+
- Specifies whether to run an Exact Nearest Neighbor (``true``) or
202+
Approximate Nearest Neighbor (``false``) search
203+
- ``false``
204204

205205
* - ``filter``
206-
- ``QueryInterface`` or ``array``
207-
- Specifies a pre-filter for documents to search on
208-
- no filtering
206+
- ``QueryInterface`` or ``array``
207+
- Specifies a pre-filter for documents to search on
208+
- no filtering
209209

210210
* - ``numCandidates``
211-
- ``int`` or ``null``
212-
- Specifies the number of nearest neighbors to use during the
213-
search
214-
- ``null``
211+
- ``int`` or ``null``
212+
- Specifies the number of nearest neighbors to use during the
213+
search
214+
- ``null``
215215

216216
To learn more about these parameters, see the :atlas:`Fields
217217
</atlas-vector-search/vector-search-stage/#fields>` section of the

source/includes/aggregation/atlas-search.php

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -17,114 +17,114 @@
1717

1818
echo "\nCreating the Atlas Search index.\n";
1919
$collection->createSearchIndex(
20-
['mappings' => ['dynamic' => true]],
20+
['mappings' => ['dynamic' => true]],
2121
);
2222

2323
// Waits for the index to be queryable
2424
wait(function () use ($collection) {
25-
echo '.';
26-
foreach ($collection->listSearchIndexes() as $index) {
27-
if ($index->name === 'default') {
28-
return $index->queryable;
29-
}
30-
}
31-
32-
return false;
25+
echo '.';
26+
foreach ($collection->listSearchIndexes() as $index) {
27+
if ($index->name === 'default') {
28+
return $index->queryable;
29+
}
30+
}
31+
32+
return false;
3333
});
3434

3535
echo "\n";
3636

3737
// start-compound-search-query
3838
$pipeline = new Pipeline(
39-
Stage::search(
40-
Search::compound(
41-
must: [
42-
Search::text(
43-
query: 'kitchen',
44-
path: 'name',
45-
),
46-
],
47-
should: [
48-
Search::text(
49-
query: 'american',
50-
path: 'cuisine',
51-
),
52-
],
53-
filter: [
54-
Search::text(
55-
query: 'Queens',
56-
path: 'borough',
57-
),
58-
],
59-
),
60-
),
61-
Stage::project(
62-
borough: 1,
63-
cuisine: 1,
64-
name: 1
65-
),
66-
Stage::limit(3)
39+
Stage::search(
40+
Search::compound(
41+
must: [
42+
Search::text(
43+
query: 'kitchen',
44+
path: 'name',
45+
),
46+
],
47+
should: [
48+
Search::text(
49+
query: 'american',
50+
path: 'cuisine',
51+
),
52+
],
53+
filter: [
54+
Search::text(
55+
query: 'Queens',
56+
path: 'borough',
57+
),
58+
],
59+
),
60+
),
61+
Stage::project(
62+
borough: 1,
63+
cuisine: 1,
64+
name: 1
65+
),
66+
Stage::limit(3)
6767
);
6868

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

7171
foreach ($cursor as $doc) {
72-
echo json_encode($doc), PHP_EOL;
72+
echo json_encode($doc), PHP_EOL;
7373
}
7474
// end-compound-search-query
7575

7676
echo "\nUpdating the Atlas Search index for autocomplete.\n";
7777
$collection->updateSearchIndex(
78-
'default',
79-
['mappings' => [
80-
"dynamic" => false,
81-
"fields" => [
82-
"name" => [
83-
["type" => "stringFacet"],
84-
["type" => "string"],
85-
[
86-
"foldDiacritics" => false,
87-
"maxGrams" => 7,
88-
"minGrams" => 3,
89-
"tokenization" => "edgeGram",
90-
"type" => "autocomplete"
91-
],
92-
]
93-
]
94-
]]
78+
'default',
79+
['mappings' => [
80+
"dynamic" => false,
81+
"fields" => [
82+
"name" => [
83+
["type" => "stringFacet"],
84+
["type" => "string"],
85+
[
86+
"foldDiacritics" => false,
87+
"maxGrams" => 7,
88+
"minGrams" => 3,
89+
"tokenization" => "edgeGram",
90+
"type" => "autocomplete"
91+
],
92+
]
93+
]
94+
]]
9595
);
9696

9797
// Waits for the index to be updated.
9898
wait(function () use ($collection) {
99-
echo '.';
100-
foreach ($collection->listSearchIndexes() as $index) {
101-
if ($index->name === 'default') {
102-
return $index->latestDefinition->mappings->fields->name[2]['type'] === 'autocomplete'
103-
&& $index->status === 'READY';
104-
}
105-
}
106-
107-
return false;
99+
echo '.';
100+
foreach ($collection->listSearchIndexes() as $index) {
101+
if ($index->name === 'default') {
102+
return $index->latestDefinition->mappings->fields->name[2]['type'] === 'autocomplete'
103+
&& $index->status === 'READY';
104+
}
105+
}
106+
107+
return false;
108108
});
109109

110110
echo "\n";
111111

112112
// start-autocomplete-search-query
113113
$pipeline = new Pipeline(
114-
Stage::search(
115-
Search::autocomplete(
116-
query: 'Lucy',
117-
path: 'name',
118-
),
119-
),
120-
Stage::limit(3),
121-
Stage::project(_id: 0, name: 1),
114+
Stage::search(
115+
Search::autocomplete(
116+
query: 'Lucy',
117+
path: 'name',
118+
),
119+
),
120+
Stage::limit(3),
121+
Stage::project(_id: 0, name: 1),
122122
);
123123

124124
$cursor = $collection->aggregate(iterator_to_array($pipeline));
125125

126126
foreach ($cursor as $doc) {
127-
echo json_encode($doc), PHP_EOL;
127+
echo json_encode($doc), PHP_EOL;
128128
}
129129
// end-autocomplete-search-query
130130

@@ -133,14 +133,14 @@
133133
*/
134134
function wait(Closure $callback): void
135135
{
136-
$timeout = hrtime()[0] + WAIT_TIMEOUT_SEC;
137-
while (hrtime()[0] < $timeout) {
138-
if ($callback()) {
139-
return;
140-
}
136+
$timeout = hrtime()[0] + WAIT_TIMEOUT_SEC;
137+
while (hrtime()[0] < $timeout) {
138+
if ($callback()) {
139+
return;
140+
}
141141

142-
sleep(5);
143-
}
142+
sleep(5);
143+
}
144144

145-
throw new RuntimeException('Time out');
145+
throw new RuntimeException('Time out');
146146
}

0 commit comments

Comments
 (0)