@@ -47,13 +47,11 @@ matches on fields indexed in a MongoDB Atlas Search index.
4747 >>> Article.objects.annotate(score=SearchEquals(path="headline", value="title"))
4848 <QuerySet [<Article: headline: title>]>
4949
50- The ``path `` argument can be either the name of a field (as a string), or a
51- :class: `~django.db.models.F ` instance.
50+ **Arguments: **
5251
53- The ``value `` argument must be a string or a :class: `~django.db.models.Value `.
54-
55- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
56- 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.
5755
5856``SearchAutocomplete ``
5957----------------------
@@ -75,16 +73,11 @@ in a MongoDB Atlas Search index.
7573 <Article: title: Harry Potter’s Cultural Impact on Literature>
7674 ]>
7775
78- The ``path `` argument specifies the field to search and can be a string or a
79- :class: `~django.db.models.F `.
80-
81- The ``query `` is the user input string to autocomplete and can be passed as a
82- string or a :class: `~django.db.models.Value `.
76+ **Arguments: **
8377
84- Optional arguments:
85-
86- - ``fuzzy ``: A dictionary with fuzzy matching options such as
87- ``{"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} ``.
8881- ``token_order ``: Controls token sequence behavior. Accepts values like
8982 ``"sequential" `` or ``"any" ``.
9083- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
@@ -109,11 +102,10 @@ documents that include (or exclude) optional fields.
109102 <Article: title: Indexing Strategies with MongoDB (by Miguel)>
110103 ]>
111104
112- The ``path `` argument specifies the document path to check and can be provided
113- as a string or a :class: `~django.db.models.F `.
105+ **Arguments: **
114106
115- The optional `` score `` argument is a :class: ` SearchScoreOption ` that tunes the
116- relevance score.
107+ - `` path ``: The document path to the field.
108+ - `` score ``: A :class: ` SearchScoreOption ` to tune the relevance score.
117109
118110``SearchIn ``
119111------------
@@ -134,12 +126,11 @@ field contains a value from the provided array.
134126 <Article: title: Boosting Relevance Scores (number=2)>
135127 ]>
136128
137- The ``path `` argument can be the name of a field (as a string) or a
138- :class: `~django.db.models.F `. The ``value `` must be a list
139- of values or a :class: `~django.db.models.Value `.
129+ **Arguments: **
140130
141- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
142- 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.
143134
144135``SearchPhrase ``
145136----------------
@@ -163,12 +154,10 @@ synonym mappings defined in the Atlas Search index.
163154 <Article: title: The Impact of Rapid Change in Climate Systems>
164155 ]>
165156
166- The ``path `` argument specifies the field to search and can be a string or a
167- :class: `~django.db.models.F `. The ``query `` is the phrase to
168- match, passed as a string or a list of strings (terms).
169-
170- Optional arguments:
157+ **Arguments: **
171158
159+ - ``path ``: The document path to the field.
160+ - ``query ``: The value to match.
172161- ``slop ``: The maximum number of terms allowed between phrase terms.
173162- ``synonyms ``: The name of a synonym mapping defined in your Atlas index.
174163- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
@@ -195,12 +184,12 @@ supports features like boolean operators, wildcards, and field-specific terms.
195184 <Article: title: Advanced Query Techniques in Django ORM>
196185 ]>
197186
198- The ``path `` argument can be a string or a
199- :class: `~django.db.models.F ` representing the field to query.
200- The ``query `` argument is a Lucene-style query string.
187+ **Arguments: **
188+
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.
201192
202- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
203- relevance score.
204193
205194``SearchRange ``
206195---------------
@@ -221,11 +210,9 @@ date, or other comparable fields based on upper and/or lower bounds.
221210 <Article: title: Pre-2020 Web Framework Evolution (number=2015)>
222211 ]>
223212
224- The ``path `` argument specifies the field to filter and can be a string or a
225- :class: `~django.db.models.F `.
226-
227- Optional arguments:
213+ **Arguments: **
228214
215+ - ``path ``: The document path to the field.
229216- ``lt ``: Exclusive upper bound (``< ``)
230217- ``lte ``: Inclusive upper bound (``<= ``)
231218- ``gt ``: Exclusive lower bound (``> ``)
@@ -251,22 +238,22 @@ expression pattern to the contents of a specified field.
251238 <Article: title: Breaking_Changes in Atlas Search API>
252239 ]>
253240
254- The ``path `` argument specifies the field to search and can be provided as a
255- string or a :class: `~django.db.models.F `. The ``query `` is a
256- regular expression string that will be applied to the field contents.
257-
258- Optional arguments:
241+ **Arguments: **
259242
243+ - ``path ``: The document path to the field.
244+ - ``query ``: Regular expression string that will be applied to the field
245+ contents.
260246- ``allow_analyzed_field ``: Boolean indicating whether to allow matching
261- against analyzed fields (defaults to `` False ``) .
247+ against analyzed fields.
262248- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
263249
264250``SearchText ``
265251--------------
266252
267253.. class :: SearchText(path, query, *, fuzzy=None, match_criteria=None, synonyms=None, score=None)
268254
269- Performs full-text search using the :doc: `text operator <atlas:atlas-search/text >`.
255+ Performs full-text search using the :doc: `text operator
256+ <atlas:atlas-search/text>`.
270257
271258Matches terms in the specified field and supports fuzzy matching, match
272259criteria, and synonym mappings.
@@ -284,16 +271,12 @@ criteria, and synonym mappings.
284271 <Article: title: Understanding MongoDB Query Optimization>
285272 ]>
286273
287- The ``path `` argument specifies the field to search and can be provided as a
288- string or a :class: `~django.db.models.F `. The ``query `` argument
289- is the search term or phrase.
290-
291- Optional arguments:
274+ **Arguments: **
292275
276+ - ``path ``: The document path to the field.
277+ - ``query ``: The argument is the search term or phrase.
293278- ``fuzzy ``: A dictionary of fuzzy matching options, such as
294279 ``{"maxEdits": 1} ``.
295- - ``match_criteria ``: Whether to match ``"all" `` or ``"any" `` terms (defaults
296- to Atlas Search behavior).
297280- ``synonyms ``: The name of a synonym mapping defined in your Atlas index.
298281- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
299282
@@ -305,8 +288,8 @@ Optional arguments:
305288Matches strings using wildcard patterns.
306289
307290Uses the :doc: `wildcard operator <atlas:atlas-search/wildcard >` to search for
308- terms matching a pattern with ``* `` (any sequence of characters) and ``? `` (any
309- single character) wildcards.
291+ terms matching a pattern with ``* `` (any sequence of characters) and ``? ``
292+ (any single character) wildcards.
310293
311294.. code-block :: pycon
312295
@@ -319,14 +302,12 @@ single character) wildcards.
319302 <Article: title: report_2022_final_review>
320303 ]>
321304
322- The ``path `` argument specifies the field to search and can be a string or a
323- :class: `~django.db.models.F `. The ``query `` is a wildcard string
324- that may include ``* `` and ``? ``.
325-
326- Optional arguments:
305+ **Arguments: **
327306
328- - ``allow_analyzed_field ``: Boolean that allows matching against analyzed
329- fields (defaults to ``False ``).
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.
330311- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
331312
332313``SearchGeoShape ``
@@ -337,8 +318,8 @@ Optional arguments:
337318Filters documents based on spatial relationships with a geometry.
338319
339320Uses the :doc: `geoShape operator <atlas:atlas-search/geoShape >` to match
340- documents where a geo field has a specified spatial relation to a given GeoJSON
341- geometry.
321+ documents where a geo field has a specified spatial relation to a given
322+ GeoJSON geometry.
342323
343324.. code-block :: pycon
344325
@@ -352,17 +333,13 @@ geometry.
352333 <Article: title: Urban Planning in District 5 (location: [1, 2])>
353334 ]>
354335
355- The ``path `` argument specifies the field to filter and can be a string or a
356- :class: `~django.db.models.F `.
357-
358- Required arguments:
336+ **Arguments: **
359337
338+ - ``path ``: The document path to the field.
360339- ``relation ``: The spatial relation to test. Valid values include
361340 ``"within" ``, ``"intersects" ``, and ``"disjoint" ``.
362341- ``geometry ``: A GeoJSON geometry object to compare against.
363-
364- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
365- relevance score.
342+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
366343
367344``SearchGeoWithin ``
368345-------------------
@@ -387,16 +364,12 @@ geometry.
387364 <Article: title: Urban Planning in District 5 (location: [1, 2])>
388365 ]>
389366
390- The ``path `` argument specifies the geo field to filter and can be a string or
391- a :class: `~django.db.models.F `.
392-
393- Required arguments:
367+ **Arguments: **
394368
369+ - ``path ``: The document path to the field.
395370- ``kind ``: The GeoJSON geometry type ``circle ``, ``box ``, or ``geometry ``.
396371- ``geo_object ``: The GeoJSON geometry defining the spatial boundary.
397-
398- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
399- relevance score.
372+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
400373
401374``SearchMoreLikeThis ``
402375----------------------
@@ -422,11 +395,12 @@ retrieve documents that resemble one or more example documents.
422395 <Article: title: Similar Approaches in Database Design>
423396 ]>
424397
425- The ``documents `` argument must be a list of example documents or expressions
426- that serve as references for similarity.
398+ **Arguments: **
399+
400+ - ``documents ``: List of example documents or expressions
401+ that serve as references for similarity.
402+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
427403
428- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
429- relevance score.
430404
431405``CompoundExpression ``
432406======================
@@ -454,64 +428,21 @@ contribute to document matching and scoring.
454428 ... )
455429 <QuerySet [<Article: title: MongoDB Atlas Database Performance Optimization>]>
456430
457- Arguments:
431+ ** Arguments: **
458432
459433- ``must ``: A list of expressions that **must ** match.
460434- ``must_not ``: A list of expressions that **must not ** match.
461- - ``should ``: A list of optional expressions that **should ** match.
462- These can improve scoring.
435+ - ``should ``: A list of optional expressions that **should ** match. These can
436+ improve scoring.
463437- ``filter ``: A list of expressions used for filtering without affecting
464438 relevance scoring.
465- - ``minimum_should_match ``: The minimum number of ``should `` clauses that
466- must match.
439+ - ``minimum_should_match ``: The minimum number of ``should `` clauses that must
440+ match.
467441- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
468442
469- ``CompoundExpression `` is useful for building advanced and flexible query
470- logic in Atlas Search.
471-
472- ``CombinedSearchExpression ``
473- ============================
474-
475- .. class :: CombinedSearchExpression(lhs, operator, rhs)
476-
477- Expression that combines two Atlas Search expressions using a boolean
478- operator.
479443
480- This expression is used internally when combining search expressions with
481- Python's bitwise operators (``& ``, ``| ``, ``~ ``), corresponding to the logical
482- operators such as ``and ``, ``or ``, and ``not ``.
483-
484- .. admonition :: Typical usage
485-
486- This expression is typically created when using the combinable interface
487- (e.g., ``expr1 & expr2 ``). It can also be constructed manually.
488-
489- .. code-block :: pycon
490-
491- >>> from django_mongodb_backend.expressions import CombinedSearchExpression
492- >>> expr1 = SearchText("headline", "mongodb")
493- >>> expr2 = SearchText("body", "atlas")
494- >>> CombinedSearchExpression(expr1, "and", expr2)
495- CombinedSearchExpression(
496- lhs=SearchText(path='headline', query='mongodb'),
497- operator='and',
498- rhs=SearchText(path='body', query='atlas')
499- )
500-
501- Args:
502-
503- - ``lhs ``: The left-hand side search expression.
504- - ``operator ``: A string representing the logical operator (``"and" ``,
505- ``"or" ``, or ``"not" ``).
506- - ``rhs ``: The right-hand side search expression.
507-
508- This is the underlying expression used to support operator overloading in
509- Atlas Search expressions.
510-
511- .. _search-operations-combinable :
512-
513- Combinable expressions
514- ----------------------
444+ ``Combinable expressions ``
445+ --------------------------
515446
516447All Atlas Search expressions subclassed from ``SearchExpression ``
517448can be combined using Python's bitwise operators:
@@ -531,10 +462,6 @@ This allows for more expressive and readable search logic:
531462 <Article: title: Modern MongoDB Features>
532463 ]>
533464
534- Under the hood, these expressions are translated into
535- :class: `CombinedSearchExpression ` instances, which can be reused and nested
536- with other compound expressions.
537-
538465 ``SearchVector ``
539466================
540467
@@ -543,8 +470,8 @@ with other compound expressions.
543470Performs vector similarity search using the :doc: `$vectorSearch stage
544471<atlas:atlas-vector-search/vector-search-stage>`.
545472
546- Retrieves documents whose vector field is most similar to a given query vector,
547- using either approximate or exact nearest-neighbor search.
473+ Retrieves documents whose vector field is most similar to a given query
474+ vector, using either approximate or exact nearest-neighbor search.
548475
549476.. code-block :: pycon
550477
@@ -560,18 +487,16 @@ using either approximate or exact nearest-neighbor search.
560487 ... )
561488 <QuerySet [<Article: Article object (6882f074359a4b191381b2e4)>]>
562489
563- Arguments:
564490
565- - ``path ``: The document path to the vector field (string or
566- :class: `~django.db.models.F `).
491+ **Arguments: **
492+
493+ - ``path ``: The document path to the field.
567494- ``query_vector ``: The input vector used for similarity comparison.
568495- ``limit ``: The maximum number of matching documents to return.
569- - ``num_candidates ``: (Optional) The number of candidate documents considered
570- during search.
571- - ``exact ``: (Optional) Whether to enforce exact search instead of approximate
572- (defaults to ``False ``).
573- - ``filter ``: (Optional) A filter expression to restrict the candidate
574- documents.
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.
575500
576501.. warning ::
577502
0 commit comments