@@ -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,12 +271,10 @@ 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} ``.
295280- ``match_criteria ``: Whether to match ``"all" `` or ``"any" `` terms (defaults
@@ -319,14 +304,12 @@ single character) wildcards.
319304 <Article: title: report_2022_final_review>
320305 ]>
321306
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:
307+ **Arguments: **
327308
328- - ``allow_analyzed_field ``: Boolean that allows matching against analyzed
329- fields (defaults to ``False ``).
309+ - ``path ``: The document path to the field.
310+ - ``query ``: A wildcard string that may include ``* `` and ``? ``.
311+ - ``allow_analyzed_field ``: Boolean indicating whether to allow matching
312+ against analyzed fields.
330313- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
331314
332315``SearchGeoShape ``
@@ -337,8 +320,8 @@ Optional arguments:
337320Filters documents based on spatial relationships with a geometry.
338321
339322Uses 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.
323+ documents where a geo field has a specified spatial relation to a given
324+ GeoJSON geometry.
342325
343326.. code-block :: pycon
344327
@@ -352,17 +335,13 @@ geometry.
352335 <Article: title: Urban Planning in District 5 (location: [1, 2])>
353336 ]>
354337
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:
338+ **Arguments: **
359339
340+ - ``path ``: The document path to the field.
360341- ``relation ``: The spatial relation to test. Valid values include
361342 ``"within" ``, ``"intersects" ``, and ``"disjoint" ``.
362343- ``geometry ``: A GeoJSON geometry object to compare against.
363-
364- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
365- relevance score.
344+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
366345
367346``SearchGeoWithin ``
368347-------------------
@@ -387,16 +366,12 @@ geometry.
387366 <Article: title: Urban Planning in District 5 (location: [1, 2])>
388367 ]>
389368
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:
369+ **Arguments: **
394370
371+ - ``path ``: The document path to the field.
395372- ``kind ``: The GeoJSON geometry type ``circle ``, ``box ``, or ``geometry ``.
396373- ``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.
374+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
400375
401376``SearchMoreLikeThis ``
402377----------------------
@@ -422,11 +397,12 @@ retrieve documents that resemble one or more example documents.
422397 <Article: title: Similar Approaches in Database Design>
423398 ]>
424399
425- The ``documents `` argument must be a list of example documents or expressions
426- that serve as references for similarity.
400+ **Arguments: **
401+
402+ - ``documents ``: List of example documents or expressions
403+ that serve as references for similarity.
404+ - ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
427405
428- The optional ``score `` argument is a :class: `SearchScoreOption ` that tunes the
429- relevance score.
430406
431407``CompoundExpression ``
432408======================
@@ -454,64 +430,21 @@ contribute to document matching and scoring.
454430 ... )
455431 <QuerySet [<Article: title: MongoDB Atlas Database Performance Optimization>]>
456432
457- Arguments:
433+ ** Arguments: **
458434
459435- ``must ``: A list of expressions that **must ** match.
460436- ``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.
437+ - ``should ``: A list of optional expressions that **should ** match. These can
438+ improve scoring.
463439- ``filter ``: A list of expressions used for filtering without affecting
464440 relevance scoring.
465- - ``minimum_should_match ``: The minimum number of ``should `` clauses that
466- must match.
441+ - ``minimum_should_match ``: The minimum number of ``should `` clauses that must
442+ match.
467443- ``score ``: A :class: `SearchScoreOption ` to tune the relevance score.
468444
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.
479445
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- ----------------------
446+ ``Combinable expressions ``
447+ --------------------------
515448
516449All Atlas Search expressions subclassed from ``SearchExpression ``
517450can be combined using Python's bitwise operators:
@@ -531,10 +464,6 @@ This allows for more expressive and readable search logic:
531464 <Article: title: Modern MongoDB Features>
532465 ]>
533466
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-
538467 ``SearchVector ``
539468================
540469
@@ -543,8 +472,8 @@ with other compound expressions.
543472Performs vector similarity search using the :doc: `$vectorSearch stage
544473<atlas:atlas-vector-search/vector-search-stage>`.
545474
546- Retrieves documents whose vector field is most similar to a given query vector,
547- using either approximate or exact nearest-neighbor search.
475+ Retrieves documents whose vector field is most similar to a given query
476+ vector, using either approximate or exact nearest-neighbor search.
548477
549478.. code-block :: pycon
550479
@@ -560,18 +489,16 @@ using either approximate or exact nearest-neighbor search.
560489 ... )
561490 <QuerySet [<Article: Article object (6882f074359a4b191381b2e4)>]>
562491
563- Arguments:
564492
565- - ``path ``: The document path to the vector field (string or
566- :class: `~django.db.models.F `).
493+ **Arguments: **
494+
495+ - ``path ``: The document path to the field.
567496- ``query_vector ``: The input vector used for similarity comparison.
568497- ``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.
498+ - ``num_candidates ``: The number of candidate documents considered during
499+ search.
500+ - ``exact ``: A boolean whether to enforce exact search instead of approximate.
501+ - ``filter ``: A MQL filter expression to restrict the candidate documents.
575502
576503.. warning ::
577504
0 commit comments