Skip to content

Commit 61888b5

Browse files
committed
Fix docstring
1 parent be5c4b7 commit 61888b5

File tree

1 file changed

+74
-44
lines changed

1 file changed

+74
-44
lines changed

django_mongodb_backend/expressions/search.py

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ class SearchAutocomplete(SearchExpression):
141141
fuzzy: Optional dictionary of fuzzy matching parameters.
142142
token_order: Optional value for `"tokenOrder"`; controls sequential vs.
143143
any-order token matching.
144-
score: Optional expression to adjust score relevance (e.g., `{"boost": {"value": 5}}`).
144+
score: Optional[SearchScore] expression to adjust score relevance
145+
(e.g., `{"boost": {"value": 5}}`).
145146
146147
Reference: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/
147148
"""
@@ -179,7 +180,8 @@ def search_operator(self, compiler, connection):
179180

180181
class SearchEquals(SearchExpression):
181182
"""
182-
Atlas Search expression that matches documents with a field equal to the given value.
183+
Atlas Search expression that matches documents with a field equal to
184+
the given value.
183185
184186
This expression uses the `equals` operator to perform exact matches
185187
on fields indexed in a MongoDB Atlas Search index.
@@ -190,7 +192,7 @@ class SearchEquals(SearchExpression):
190192
Args:
191193
path: The document path to compare (as string or expression).
192194
value: The exact value to match against.
193-
score: Optional expression to modify the relevance score.
195+
score: Optional[SearchScore] expression to modify the relevance score.
194196
195197
Reference: https://www.mongodb.com/docs/atlas/atlas-search/equals/
196198
"""
@@ -233,7 +235,7 @@ class SearchExists(SearchExpression):
233235
234236
Args:
235237
path: The document path to check (as string or expression).
236-
score: Optional expression to modify the relevance score.
238+
score: Optional[SearchScore] expression to modify the relevance score.
237239
238240
Reference: https://www.mongodb.com/docs/atlas/atlas-search/exists/
239241
"""
@@ -263,7 +265,8 @@ def search_operator(self, compiler, connection):
263265

264266
class SearchIn(SearchExpression):
265267
"""
266-
Atlas Search expression that matches documents where the field value is in a given list.
268+
Atlas Search expression that matches documents where the field value
269+
is in a given list.
267270
268271
This expression uses the `in` operator to match documents whose field
269272
contains a value from the provided array of values.
@@ -274,7 +277,7 @@ class SearchIn(SearchExpression):
274277
Args:
275278
path: The document path to match against (as string or expression).
276279
value: A list of values to check for membership.
277-
score: Optional expression to adjust the relevance score.
280+
score: Optional[SearchScore] expression to adjust the relevance score.
278281
279282
Reference: https://www.mongodb.com/docs/atlas/atlas-search/in/
280283
"""
@@ -309,7 +312,8 @@ class SearchPhrase(SearchExpression):
309312
Atlas Search expression that matches a phrase in the specified field.
310313
311314
This expression uses the `phrase` operator to search for exact or near exact
312-
sequences of terms. It supports optional slop (word distance) and synonym sets.
315+
sequences of terms. It supports optional slop (word distance)
316+
and synonym sets.
313317
314318
Example:
315319
SearchPhrase("description__text", "climate change", slop=2)
@@ -318,8 +322,9 @@ class SearchPhrase(SearchExpression):
318322
path: The document path to search (as string or expression).
319323
query: The phrase to match as a single string or list of terms.
320324
slop: Optional maximum word distance allowed between phrase terms.
321-
synonyms: Optional name of a synonym mapping defined in the Atlas index.
322-
score: Optional expression to modify the relevance score.
325+
synonyms: Optional name of a synonym mapping defined in the
326+
Atlas index.
327+
score: Optional[SearchScore] expression to modify the relevance score.
323328
324329
Reference: https://www.mongodb.com/docs/atlas/atlas-search/phrase/
325330
"""
@@ -361,15 +366,16 @@ class SearchQueryString(SearchExpression):
361366
362367
This expression uses the `queryString` operator to parse and execute
363368
full-text queries written in a simplified Lucene syntax. It supports
364-
advanced constructs like boolean operators, wildcards, and field-specific terms.
369+
advanced constructs like boolean operators, wildcards,
370+
and field-specific terms.
365371
366372
Example:
367373
SearchQueryString("content__text", "django AND (search OR query)")
368374
369375
Args:
370376
path: The document path to query (as string or expression).
371377
query: The Lucene-style query string.
372-
score: Optional expression to modify the relevance score.
378+
score: Optional[SearchScore] expression to modify the relevance score.
373379
374380
Reference: https://www.mongodb.com/docs/atlas/atlas-search/queryString/
375381
"""
@@ -415,7 +421,7 @@ class SearchRange(SearchExpression):
415421
lte: Optional inclusive upper bound (`<=`).
416422
gt: Optional exclusive lower bound (`>`).
417423
gte: Optional inclusive lower bound (`>=`).
418-
score: Optional expression to modify the relevance score.
424+
score: Optional[SearchScore] expression to modify the relevance score.
419425
420426
Reference: https://www.mongodb.com/docs/atlas/atlas-search/range/
421427
"""
@@ -468,8 +474,9 @@ class SearchRegex(SearchExpression):
468474
Args:
469475
path: The document path to match (as string or expression).
470476
query: The regular expression pattern to apply.
471-
allow_analyzed_field: Whether to allow matching against analyzed fields (default is False).
472-
score: Optional expression to modify the relevance score.
477+
allow_analyzed_field: Whether to allow matching against analyzed
478+
fields (default is False).
479+
score: Optional[SearchScore] expression to modify the relevance score.
473480
474481
Reference: https://www.mongodb.com/docs/atlas/atlas-search/regex/
475482
"""
@@ -510,15 +517,22 @@ class SearchText(SearchExpression):
510517
fuzzy matching, match criteria, and synonyms.
511518
512519
Example:
513-
SearchText("description__content", "mongodb", fuzzy={"maxEdits": 1}, match_criteria="all")
520+
SearchText(
521+
"description__content",
522+
"mongodb",
523+
fuzzy={"maxEdits": 1},
524+
match_criteria="all"
525+
)
514526
515527
Args:
516528
path: The document path to search (as string or expression).
517529
query: The search term or phrase.
518530
fuzzy: Optional dictionary to configure fuzzy matching parameters.
519-
match_criteria: Optional criteria for term matching (e.g., "all" or "any").
520-
synonyms: Optional name of a synonym mapping defined in the Atlas index.
521-
score: Optional expression to adjust relevance scoring.
531+
match_criteria: Optional criteria for term matching
532+
(e.g., "all" or "any").
533+
synonyms: Optional name of a synonym mapping defined in the
534+
Atlas index.
535+
score: Optional[SearchScore] expression to adjust relevance scoring.
522536
523537
Reference: https://www.mongodb.com/docs/atlas/atlas-search/text/
524538
"""
@@ -570,8 +584,9 @@ class SearchWildcard(SearchExpression):
570584
Args:
571585
path: The document path to search (as string or expression).
572586
query: The wildcard pattern to match.
573-
allow_analyzed_field: Whether to allow matching against analyzed fields (default is False).
574-
score: Optional expression to modify the relevance score.
587+
allow_analyzed_field: Whether to allow matching against analyzed
588+
fields (default is False).
589+
score: Optional[SearchScore] expression to modify the relevance score.
575590
576591
Reference: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/
577592
"""
@@ -606,19 +621,22 @@ def search_operator(self, compiler, connection):
606621

607622
class SearchGeoShape(SearchExpression):
608623
"""
609-
Atlas Search expression that filters documents by spatial relationship with a geometry.
624+
Atlas Search expression that filters documents by spatial relationship
625+
with a geometry.
610626
611627
This expression uses the `geoShape` operator to match documents where
612628
a geo field relates to a specified geometry by a spatial relation.
613629
614630
Example:
615-
SearchGeoShape("location", "within", {"type": "Polygon", "coordinates": [...]})
631+
SearchGeoShape("location", "within",
632+
{"type": "Polygon", "coordinates": [...]})
616633
617634
Args:
618635
path: The document path to the geo field (as string or expression).
619-
relation: The spatial relation to test (e.g., "within", "intersects", "disjoint").
636+
relation: The spatial relation to test
637+
(e.g., "within", "intersects", "disjoint").
620638
geometry: The GeoJSON geometry to compare against.
621-
score: Optional expression to modify the relevance score.
639+
score: Optional[SearchScore] expression to modify the relevance score.
622640
623641
Reference: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/
624642
"""
@@ -659,13 +677,14 @@ class SearchGeoWithin(SearchExpression):
659677
the geo field lies entirely within the given geometry.
660678
661679
Example:
662-
SearchGeoWithin("location", "Polygon", {"type": "Polygon", "coordinates": [...]})
680+
SearchGeoWithin("location", "Polygon",
681+
{"type": "Polygon", "coordinates": [...]})
663682
664683
Args:
665684
path: The document path to the geo field (as string or expression).
666685
kind: The GeoJSON geometry type (e.g., "Polygon", "MultiPolygon").
667686
geo_object: The GeoJSON geometry defining the boundary.
668-
score: Optional expression to adjust the relevance score.
687+
score: Optional[SearchScore] expression to adjust the relevance score.
669688
670689
Reference: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/
671690
"""
@@ -707,8 +726,10 @@ class SearchMoreLikeThis(SearchExpression):
707726
SearchMoreLikeThis([{"_id": ObjectId("...")}, {"title": "Example"}])
708727
709728
Args:
710-
documents: A list of example documents or expressions to find similar documents.
711-
score: Optional expression to modify the relevance scoring.
729+
documents: A list of example documents or expressions to find similar
730+
documents.
731+
score: Optional[SearchScore] expression to modify the relevance
732+
scoring.
712733
713734
Reference: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/
714735
"""
@@ -741,11 +762,12 @@ def get_search_fields(self, compiler, connection):
741762

742763
class CompoundExpression(SearchExpression):
743764
"""
744-
Compound expression that combines multiple search clauses using boolean logic.
765+
Compound expression that combines multiple search clauses using boolean
766+
logic.
745767
746-
This expression corresponds to the `compound` operator in MongoDB Atlas Search,
747-
allowing fine-grained control by combining multiple sub-expressions with
748-
`must`, `must_not`, `should`, and `filter` clauses.
768+
This expression corresponds to the `compound` operator in MongoDB Atlas
769+
Search, allowing fine-grained control by combining multiple
770+
sub-expressions with `must`, `must_not`, `should`, and `filter` clauses.
749771
750772
Example:
751773
CompoundExpression(
@@ -758,10 +780,13 @@ class CompoundExpression(SearchExpression):
758780
Args:
759781
must: List of expressions that **must** match.
760782
must_not: List of expressions that **must not** match.
761-
should: List of expressions that **should** match (optional relevance boost).
762-
filter: List of expressions to filter results without affecting relevance.
763-
score: Optional expression to adjust scoring.
764-
minimum_should_match: Minimum number of `should` clauses that must match.
783+
should: List of expressions that **should** match
784+
(optional relevance boost).
785+
filter: List of expressions to filter results without affecting
786+
relevance.
787+
score: Optional[SearchScore] expression to adjust scoring.
788+
minimum_should_match: Minimum number of `should` clauses that
789+
must match.
765790
766791
Reference: https://www.mongodb.com/docs/atlas/atlas-search/compound/
767792
"""
@@ -884,22 +909,27 @@ def as_mql(self, compiler, connection):
884909

885910
class SearchVector(SearchExpression):
886911
"""
887-
Atlas Search expression that performs vector similarity search using `$vectorSearch`.
912+
Atlas Search expression that performs vector similarity search
913+
using `$vectorSearch`.
888914
889-
This expression uses the `$vectorSearch` stage to retrieve documents whose vector
890-
embeddings are most similar to a given query vector, according to approximate or
891-
exact nearest-neighbor search.
915+
This expression uses the `$vectorSearch` stage to retrieve documents
916+
whose vector embeddings are most similar to a given query vector,
917+
according to approximate or exact nearest-neighbor search.
892918
893919
Example:
894-
SearchVector("embedding", [0.1, 0.2, 0.3], limit=10, num_candidates=100)
920+
SearchVector("embedding", [0.1, 0.2, 0.3], limit=10,
921+
num_candidates=100)
895922
896923
Args:
897924
path: The document path to the vector field (as string or expression).
898925
query_vector: The query vector to compare against.
899926
limit: Maximum number of matching documents to return.
900-
num_candidates: Optional number of candidates to consider during search.
901-
exact: Optional flag to enforce exact matching (default is approximate).
902-
filter: Optional filter expression to narrow candidate documents.
927+
num_candidates: Optional number of candidates to consider
928+
during search.
929+
exact: Optional flag to enforce exact matching (default is
930+
approximate).
931+
filter: Optional raw mql filter expression to narrow
932+
candidate documents.
903933
904934
Reference: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/
905935
"""

0 commit comments

Comments
 (0)