Skip to content

Commit 91e0cb8

Browse files
committed
fix code examples
1 parent 1e1cf71 commit 91e0cb8

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

source/atlas-search.txt

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,48 +63,50 @@ The query also includes a:
6363
- :pipeline:`$project` stage to exclude all fields except
6464
``title`` and add a field named ``score``.
6565

66-
.. code-block:: python
66+
.. io-code-block::
6767
:copyable: true
68+
69+
.. input:: python
6870

69-
client = pymongo.MongoClient('<connection-string>')
70-
result = client['sample_mflix']['movies'].aggregate([
71-
{
72-
"$search": {
73-
"phrase": {
71+
client = pymongo.MongoClient('<connection-string>')
72+
result = client['sample_mflix']['movies'].aggregate([
73+
{
74+
"$search": {
75+
"phrase": {
7476
"path": "title",
7577
"query": "new york"
7678
}
7779
}
7880
},
7981
{ $limit: 10 },
8082
{
81-
$project: {
82-
"_id": 0,
83-
"title": 1,
84-
score: { $meta: "searchScore" }
83+
$project: {
84+
"_id": 0,
85+
"title": 1,
86+
score: { $meta: "searchScore" }
8587
}
8688
}
8789
])
88-
for i in result:
89-
print(i)
90-
91-
.. output::
92-
:language: shell
93-
:linenos:
94-
:visible: false
95-
96-
[
97-
{ title: 'New York, New York', score: 6.786321640014648 }
98-
{ title: 'New York', score: 6.258549213409424 }
99-
{ title: 'New York Stories', score: 5.3813982009887695 }
100-
{ title: 'New York Minute', score: 5.3813982009887695 }
101-
{ title: 'Synecdoche, New York', score: 5.3813982009887695 }
102-
{ title: 'New York Doll', score: 5.3813982009887695 }
103-
{ title: 'Little New York', score: 5.3813982009887695 }
104-
{ title: 'Escape from New York', score: 4.719893455505371 }
105-
{ title: 'Naked in New York', score: 4.719893455505371 }
106-
{ title: 'Autumn in New York', score: 4.719893455505371 }
107-
]
90+
for i in result:
91+
print(i)
92+
93+
.. output::
94+
:language: shell
95+
:linenos:
96+
:visible: false
97+
98+
[
99+
{ title: 'New York, New York', score: 6.786321640014648 }
100+
{ title: 'New York', score: 6.258549213409424 }
101+
{ title: 'New York Stories', score: 5.3813982009887695 }
102+
{ title: 'New York Minute', score: 5.3813982009887695 }
103+
{ title: 'Synecdoche, New York', score: 5.3813982009887695 }
104+
{ title: 'New York Doll', score: 5.3813982009887695 }
105+
{ title: 'Little New York', score: 5.3813982009887695 }
106+
{ title: 'Escape from New York', score: 4.719893455505371 }
107+
{ title: 'Naked in New York', score: 4.719893455505371 }
108+
{ title: 'Autumn in New York', score: 4.719893455505371 }
109+
]
108110

109111
Next Steps
110112
----------

0 commit comments

Comments
 (0)