Skip to content

Commit fde6b8c

Browse files
committed
change query example
1 parent 4c4d580 commit fde6b8c

File tree

1 file changed

+50
-26
lines changed

1 file changed

+50
-26
lines changed

source/atlas-search.txt

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Atlas Search
2020
Overview
2121
--------
2222

23-
In this guide, you can learn how to query an Atlas Search index and use advanced search
24-
functionality in your {+driver-short+} applications. You can query a search index by
23+
In this guide, you can learn how to query an Atlas Search index and use advanced full-text
24+
search functionality in your {+driver-short+} applications. You can query a search index by
2525
using a ``$search`` aggregation pipeline stage.
2626

2727
To learn more about the ``$search`` pipeline stage, see the :manual:`$search
@@ -48,7 +48,7 @@ Create an Atlas Search Index
4848

4949
Before you can perform a search on an Atlas collection, you must first create an **Atlas
5050
Search index** on the collection. An Atlas Search index is a data structure that
51-
categorizes data in a searchable format. To learn how to create an Atlas Search Index,
51+
categorizes data in a searchable format. To learn how to create an Atlas Search index,
5252
see :ref:`pymongo-atlas-search-index`.
5353

5454
Search Your Data
@@ -79,23 +79,41 @@ The query also includes the following stages:
7979
client = pymongo.MongoClient("<connection-string>")
8080
result = client["sample_mflix"]["movies"].aggregate([
8181
{
82-
"$search": {
83-
"index": "pymongoindex",
84-
"phrase": {
85-
"path": "title",
86-
"query": "new york"
87-
}
88-
}
82+
"$search": {
83+
"index": "pymongoindex",
84+
"compound": {
85+
"mustNot": [
86+
{
87+
"text": {
88+
"query": [
89+
"Comedy"
90+
],
91+
"path": "genres"
92+
}
93+
}
94+
],
95+
"must": [
96+
{
97+
"text": {
98+
"query": [
99+
"new york"
100+
],
101+
"path": "title"
102+
}
103+
}
104+
],
105+
}
106+
}
89107
},
90108
{ "$limit": 10 },
91109
{
92110
"$project": {
93111
"_id": 0,
94112
"title": 1,
95113
"score": { "$meta": "searchScore" }
96-
}
97-
}
98-
])
114+
}
115+
}
116+
])
99117

100118
for i in result:
101119
print(i)
@@ -104,21 +122,27 @@ The query also includes the following stages:
104122
:language: none
105123
:visible: false
106124

107-
{ title: 'New York, New York', score: 6.786321640014648 }
108-
{ title: 'New York', score: 6.258549213409424 }
109-
{ title: 'New York Stories', score: 5.3813982009887695 }
110-
{ title: 'New York Minute', score: 5.3813982009887695 }
111-
{ title: 'Synecdoche, New York', score: 5.3813982009887695 }
112-
{ title: 'New York Doll', score: 5.3813982009887695 }
113-
{ title: 'Little New York', score: 5.3813982009887695 }
114-
{ title: 'Escape from New York', score: 4.719893455505371 }
115-
{ title: 'Naked in New York', score: 4.719893455505371 }
116-
{ title: 'Autumn in New York', score: 4.719893455505371 }
125+
{'title': 'New York, New York', 'score': 6.786379814147949}
126+
{'title': 'New York', 'score': 6.258603096008301}
127+
{'title': 'New York Doll', 'score': 5.381444931030273}
128+
{'title': 'Escape from New York', 'score': 4.719935417175293}
129+
{'title': 'Autumn in New York', 'score': 4.719935417175293}
130+
{'title': 'Sleepless in New York', 'score': 4.719935417175293}
131+
{'title': 'Gangs of New York', 'score': 4.719935417175293}
132+
{'title': 'Sherlock Holmes in New York', 'score': 4.203253746032715}
133+
{'title': 'New York: A Documentary Film', 'score': 4.203253746032715}
134+
{'title': 'An Englishman in New York', 'score': 4.203253746032715}
117135

118136
Additional Information
119137
----------------------
120138

121-
To learn more about the available Atlas Search operators, see the :atlas:`Operators and Collectors </atlas-search/operators-and-collectors>` guide in the MongoDB Atlas documentation.
122-
139+
To learn more about the available Atlas Search operators, see the :atlas:`Operators and
140+
Collectors </atlas-search/operators-and-collectors>` guide in the MongoDB Atlas
141+
documentation.
142+
ß
123143
For more information about Atlas Search, and to view more query examples, see the
124-
:atlas:`Atlas Search documentation </atlas-search>`.
144+
:atlas:`Atlas Search documentation </atlas-search>`.
145+
146+
If you'd like to perform vector searches on your data stored in Atlas, you must use Atlas
147+
Vector Search. To learn more about Atlas Vector Search, see the :atlas:`Atlas Vector
148+
Search documentation </atlas-vector-search/vector-search-overview/>`.

0 commit comments

Comments
 (0)