@@ -31,6 +31,9 @@ For the examples in this document, we'll use the following models::
31
31
plot_embedding = ArrayField(models.FloatField(), size=3, null=True)
32
32
writer = EmbeddedModelField(Writer, null=True)
33
33
34
+ ``SearchEquals ``
35
+ ----------------
36
+
34
37
.. class :: SearchEquals(path, value, *, score=None)
35
38
36
39
Matches documents where a field is equal to a given value.
@@ -46,13 +49,12 @@ matches on fields indexed in a MongoDB Atlas Search index.
46
49
47
50
**Arguments: **
48
51
49
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
50
- to the field.
51
- - ``value `` (``bool ``, :class: `~bson.objectid.ObjectId `, ``int ``,
52
- :class: `~datetime.datetime `, ``str ``, :class: `~uuid.UUID `, ``None ``, or
53
- :class: `~django.db.models.Value `): The value to match.
54
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
55
- Tunes the relevance score.
52
+ - ``path ``: The document path to the field.
53
+ - ``value ``: The value to match.
54
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
55
+
56
+ ``SearchAutocomplete ``
57
+ ----------------------
56
58
57
59
.. class :: SearchAutocomplete(path, query, *, fuzzy=None, token_order=None, score=None)
58
60
@@ -73,15 +75,15 @@ in a MongoDB Atlas Search index.
73
75
74
76
**Arguments: **
75
77
76
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
77
- to the field.
78
- - ``query `` (``str ``, :class: `~django.db.models.Value `): The value to match.
79
- - ``fuzzy `` (:class: `~typing.Optional `\[ :class: `~typing.Dict `\] ): Fuzzy
80
- matching options, e.g., ``{"maxEdits": 1} ``.
78
+ - ``path ``: The document path to the field.
79
+ - ``query ``: The value to match.
80
+ - ``fuzzy ``: Fuzzy matching options, e.g., ``{"maxEdits": 1} ``.
81
81
- ``token_order ``: Controls token sequence behavior. Accepts values like
82
82
``"sequential" `` or ``"any" ``.
83
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
84
- Tunes the relevance score.
83
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
84
+
85
+ ``SearchExists ``
86
+ ----------------
85
87
86
88
.. class :: SearchExists(path, *, score=None)
87
89
@@ -102,10 +104,11 @@ documents that include (or exclude) optional fields.
102
104
103
105
**Arguments: **
104
106
105
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
106
- to the field.
107
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
108
- Tunes the relevance score.
107
+ - ``path ``: The document path to the field.
108
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
109
+
110
+ ``SearchIn ``
111
+ ------------
109
112
110
113
.. class :: SearchIn(path, value, *, score=None)
111
114
@@ -125,13 +128,12 @@ field contains a value from the provided array.
125
128
126
129
**Arguments: **
127
130
128
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
129
- to the field.
130
- - ``value `` (``bool ``, ``int ``, ``str ``, :class: `~bson.objectid.ObjectId `,
131
- :class: `~datetime.datetime `, :class: `~uuid.UUID `, or
132
- :class: `~django.db.models.Value `): The value to match.
133
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
134
- Tunes the relevance score.
131
+ - ``path ``: The document path to the field.
132
+ - ``value ``: The value to match.
133
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
134
+
135
+ ``SearchPhrase ``
136
+ ----------------
135
137
136
138
.. class :: SearchPhrase(path, query, *, slop=None, synonyms=None, score=None)
137
139
@@ -154,16 +156,14 @@ synonym mappings defined in the Atlas Search index.
154
156
155
157
**Arguments: **
156
158
157
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
158
- to the field.
159
- - ``query `` (``str ``, :class: `~django.db.models.Value `): The value to match.
160
- - ``slop `` (``Optional[int] ``): The maximum number of
161
- terms allowed between phrase terms.
162
- - ``synonyms `` (``Optional[str] ``): The name of a synonym
163
- mapping defined in your Atlas index.
164
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
165
- Tunes the relevance score.
159
+ - ``path ``: The document path to the field.
160
+ - ``query ``: The value to match.
161
+ - ``slop ``: The maximum number of terms allowed between phrase terms.
162
+ - ``synonyms ``: The name of a synonym mapping defined in your Atlas index.
163
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
166
164
165
+ ``SearchQueryString ``
166
+ ---------------------
167
167
168
168
.. class :: SearchQueryString(path, query, *, score=None)
169
169
@@ -186,12 +186,13 @@ supports features like boolean operators, wildcards, and field-specific terms.
186
186
187
187
**Arguments: **
188
188
189
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
190
- to the field.
191
- - ``query `` (``str ``, :class: `~django.db.models.Value `): argument is a
192
- Lucene-style query string.
193
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ): Tunes
194
- the relevance score.
189
+ - ``path ``: The document path to the field.
190
+ - ``query ``: A Lucene-style query string.
191
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
192
+
193
+
194
+ ``SearchRange ``
195
+ ---------------
195
196
196
197
.. class :: SearchRange(path, *, lt=None, lte=None, gt=None, gte=None, score=None)
197
198
@@ -211,22 +212,15 @@ date, or other comparable fields based on upper and/or lower bounds.
211
212
212
213
**Arguments: **
213
214
214
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
215
- to the field.
216
- - ``lt `` (``bool ``, :class: `~bson.objectid.ObjectId `, ``int ``,
217
- :class: `~datetime.datetime `, ``str ``, :class: `~uuid.UUID `, or
218
- :class: `~django.db.models.Value `): Exclusive upper bound (``< ``)
219
- - ``lte `` (``bool ``, :class: `~bson.objectid.ObjectId `, ``int ``,
220
- :class: `~datetime.datetime `, ``str ``, :class: `~uuid.UUID `, or
221
- :class: `~django.db.models.Value `): Inclusive upper bound (``<= ``)
222
- - ``gt `` (``bool ``, :class: `~bson.objectid.ObjectId `, ``int ``,
223
- :class: `~datetime.datetime `, ``str ``, :class: `~uuid.UUID `, or
224
- :class: `~django.db.models.Value `): Exclusive lower bound (``> ``)
225
- - ``gte `` (``bool ``, :class: `~bson.objectid.ObjectId `, ``int ``,
226
- :class: `~datetime.datetime `, ``str ``, :class: `~uuid.UUID `, or
227
- :class: `~django.db.models.Value `): Inclusive lower bound (``>= ``)
228
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
229
- Tunes the relevance score.
215
+ - ``path ``: The document path to the field.
216
+ - ``lt ``: Exclusive upper bound (``< ``)
217
+ - ``lte ``: Inclusive upper bound (``<= ``)
218
+ - ``gt ``: Exclusive lower bound (``> ``)
219
+ - ``gte ``: Inclusive lower bound (``>= ``)
220
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
221
+
222
+ ``SearchRegex ``
223
+ ---------------
230
224
231
225
.. class :: SearchRegex(path, query, *, allow_analyzed_field=None, score=None)
232
226
@@ -246,14 +240,15 @@ expression pattern to the contents of a specified field.
246
240
247
241
**Arguments: **
248
242
249
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
250
- to the field.
251
- - ``query `` (``str ``, :class: `~django.db.models.Value `): regular expression
252
- string that will be applied to the field contents.
253
- - ``allow_analyzed_field `` (``Optional[bool] ``): Boolean
254
- indicating whether to allow matching against analyzed fields.
255
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
256
- Tunes the relevance score.
243
+ - ``path ``: The document path to the field.
244
+ - ``query ``: Regular expression string that will be applied to the field
245
+ contents.
246
+ - ``allow_analyzed_field ``: Boolean indicating whether to allow matching
247
+ against analyzed fields.
248
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
249
+
250
+ ``SearchText ``
251
+ --------------
257
252
258
253
.. class :: SearchText(path, query, *, fuzzy=None, match_criteria=None, synonyms=None, score=None)
259
254
@@ -278,17 +273,15 @@ criteria, and synonym mappings.
278
273
279
274
**Arguments: **
280
275
281
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
282
- to the field.
283
- - ``query `` (``str ``, :class: `~django.db.models.Value `): argument
284
- is the search term or phrase.
285
- - ``fuzzy `` (``Optional[Dict] ``): A dictionary of fuzzy
286
- matching options, such as ``{"maxEdits": 1} ``.
287
- - ``synonyms `` (``Optional[str] ``): The name of a synonym
288
- mapping defined in your Atlas index.
289
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
290
- Tunes the relevance score.
276
+ - ``path ``: The document path to the field.
277
+ - ``query ``: The argument is the search term or phrase.
278
+ - ``fuzzy ``: A dictionary of fuzzy matching options, such as
279
+ ``{"maxEdits": 1} ``.
280
+ - ``synonyms ``: The name of a synonym mapping defined in your Atlas index.
281
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
291
282
283
+ ``SearchWildcard ``
284
+ ------------------
292
285
293
286
.. class :: SearchWildcard(path, query, allow_analyzed_field=None, score=None)
294
287
@@ -311,14 +304,14 @@ terms matching a pattern with ``*`` (any sequence of characters) and ``?``
311
304
312
305
**Arguments: **
313
306
314
- - ``path `` (`` str `` or :class: ` ~django.db.models.F `): The document path
315
- to the field .
316
- - ``query `` (`` str ``, :class: ` ~django.db.models.Value `): is a wildcard string
317
- that may include `` * `` and `` ? `` .
318
- - ``allow_analyzed_field `` (`` Optional[bool] ``): Boolean
319
- indicating whether to allow matching against analyzed fields.
320
- - `` score `` ( :class: ` ~typing.Optional ` \[ :class: ` SearchScoreOption ` \] ):
321
- Tunes the relevance score.
307
+ - ``path ``: The document path to the field.
308
+ - `` query ``: A wildcard string that may include `` * `` and `` ? `` .
309
+ - ``allow_analyzed_field ``: Boolean indicating whether to allow matching
310
+ against analyzed fields .
311
+ - ``score ``: A :class: ` SearchScoreOption ` to tune the relevance score.
312
+
313
+ `` SearchGeoShape ``
314
+ ------------------
322
315
323
316
.. class :: SearchGeoShape(path, relation, geometry, *, score=None)
324
317
@@ -342,14 +335,14 @@ GeoJSON geometry.
342
335
343
336
**Arguments: **
344
337
345
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
346
- to the field.
347
- - ``relation `` (``str ``): The spatial relation to test. Valid
348
- values include ``"within" ``, ``"intersects" ``, and ``"disjoint" ``.
349
- - ``geometry `` (``Dict ``): A GeoJSON geometry object to compare against.
350
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
351
- Tunes the relevance score.
338
+ - ``path ``: The document path to the field.
339
+ - ``relation ``: The spatial relation to test. Valid values include
340
+ ``"within" ``, ``"intersects" ``, and ``"disjoint" ``.
341
+ - ``geometry ``: A GeoJSON geometry object to compare against.
342
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
352
343
344
+ ``SearchGeoWithin ``
345
+ -------------------
353
346
354
347
.. class :: SearchGeoWithin(path, kind, geometry, *, score=None)
355
348
@@ -373,15 +366,13 @@ geometry.
373
366
374
367
**Arguments: **
375
368
376
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
377
- to the field.
378
- - ``kind `` (``str ``): The GeoJSON geometry type ``circle ``, ``box ``, or
379
- ``geometry ``.
380
- - ``geo_object `` (``Dict ``): The GeoJSON geometry defining the spatial
381
- boundary.
382
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
383
- Tunes the relevance score.
369
+ - ``path ``: The document path to the field.
370
+ - ``kind ``: The GeoJSON geometry type ``circle ``, ``box ``, or ``geometry ``.
371
+ - ``geo_object ``: The GeoJSON geometry defining the spatial boundary.
372
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
384
373
374
+ ``SearchMoreLikeThis ``
375
+ ----------------------
385
376
386
377
.. class :: SearchMoreLikeThis(documents, *, score=None)
387
378
@@ -406,10 +397,9 @@ retrieve documents that resemble one or more example documents.
406
397
407
398
**Arguments: **
408
399
409
- - ``documents `` (`` List[Dict] ``) : List of example documents or expressions
400
+ - ``documents ``: List of example documents or expressions
410
401
that serve as references for similarity.
411
- - ``score `` (:class: `~typing.Optional `\[ :class: `SearchScoreOption `\] ):
412
- Tunes the relevance score.
402
+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
413
403
414
404
415
405
``CompoundExpression ``
@@ -440,21 +430,19 @@ contribute to document matching and scoring.
440
430
441
431
**Arguments: **
442
432
443
- - ``must `` (``List[SearchExpression]) ``): List of expressions that **must **
433
+ - ``must ``: List of expressions that **must ** match.
434
+ - ``must_not ``: List of expressions that **must not ** match.
435
+ - ``should ``: List of optional expressions that **should ** match. These can
436
+ improve scoring.
437
+ - ``filter ``: List of expressions used for filtering without affecting
438
+ relevance scoring.
439
+ - ``minimum_should_match ``: The minimum number of ``should `` clauses that must
444
440
match.
445
- - ``must_not `` (``List[SearchExpression] ``): List of expressions that
446
- **must not ** match.
447
- - ``should `` (``List[SearchExpression] ``): List of optional expressions that
448
- **should ** match. These can improve scoring.
449
- - ``filter `` (``List[SearchExpression] ``): List of expressions used for
450
- filtering without affecting relevance scoring.
451
- - ``minimum_should_match `` (``Optional[int] ``): The minimum number of
452
- ``should `` clauses that must match.
453
441
- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
454
442
455
443
456
- Combinable expressions
457
- ----------------------
444
+ `` Combinable expressions ``
445
+ --------------------------
458
446
459
447
All Atlas Search expressions subclassed from ``SearchExpression ``
460
448
can be combined using Python's bitwise operators:
@@ -502,17 +490,13 @@ vector, using either approximate or exact nearest-neighbor search.
502
490
503
491
**Arguments: **
504
492
505
- - ``path `` (``str `` or :class: `~django.db.models.F `): The document path
506
- to the field.
507
- - ``query_vector `` (``List[float | int] ``): The input vector used for
508
- similarity comparison.
509
- - ``limit `` (``int ``): The maximum number of matching documents to return.
510
- - ``num_candidates `` (``int ``): The number of candidate documents considered
511
- during search.
512
- - ``exact `` (``bool ``): Whether to enforce exact search instead of
513
- approximate.
514
- - ``filter `` (``dict ``): A filter MQL expression to restrict the candidate
515
- documents.
493
+ - ``path ``: The document path to the field.
494
+ - ``query_vector ``: The input vector used for similarity comparison.
495
+ - ``limit ``: The maximum number of matching documents to return.
496
+ - ``num_candidates ``: The number of candidate documents considered during
497
+ search.
498
+ - ``exact ``: A boolean whether to enforce exact search instead of approximate.
499
+ - ``filter ``: A MQL filter expression to restrict the candidate documents.
516
500
517
501
.. warning ::
518
502
0 commit comments