@@ -71,7 +71,7 @@ def __or__(self, other):
7171 return self ._combine (other , Operator (Operator .OR ))
7272
7373 def __ror__ (self , other ):
74- return self ._combine (self , Operator (Operator .OR ), other )
74+ return self ._combine (other , Operator (Operator .OR ))
7575
7676
7777class SearchExpression (SearchCombinable , Expression ):
@@ -101,10 +101,14 @@ def get_source_expressions(self):
101101 return []
102102
103103 def _get_indexed_fields (self , mappings ):
104- for field , definition in mappings .get ("fields" , {}).items ():
105- yield field
106- for path in self ._get_indexed_fields (definition ):
107- yield f"{ field } .{ path } "
104+ if isinstance (mappings , list ):
105+ for definition in mappings :
106+ yield from self ._get_indexed_fields (definition )
107+ else :
108+ for field , definition in mappings .get ("fields" , {}).items ():
109+ yield field
110+ for path in self ._get_indexed_fields (definition ):
111+ yield f"{ field } .{ path } "
108112
109113 def _get_query_index (self , fields , compiler ):
110114 fields = set (fields )
@@ -142,9 +146,7 @@ class SearchAutocomplete(SearchExpression):
142146 any-order token matching.
143147 score: Optional expression to adjust score relevance (e.g., `{"boost": {"value": 5}}`).
144148
145- Notes:
146- * Requires an Atlas Search index with `autocomplete` mappings.
147- * The operator is injected under the `$search` stage in the aggregation pipeline.
149+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/
148150 """
149151
150152 def __init__ (self , path , query , fuzzy = None , token_order = None , score = None ):
@@ -193,10 +195,7 @@ class SearchEquals(SearchExpression):
193195 value: The exact value to match against.
194196 score: Optional expression to modify the relevance score.
195197
196- Notes:
197- * The field must be indexed with a supported type for `equals`.
198- * Supports numeric, string, boolean, and date values.
199- * Score boosting can be applied using the `score` parameter.
198+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/equals/
200199 """
201200
202201 def __init__ (self , path , value , score = None ):
@@ -239,9 +238,7 @@ class SearchExists(SearchExpression):
239238 path: The document path to check (as string or expression).
240239 score: Optional expression to modify the relevance score.
241240
242- Notes:
243- * The target field must be mapped in the Atlas Search index.
244- * This does not test for null—only for presence.
241+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/exists/
245242 """
246243
247244 def __init__ (self , path , score = None ):
@@ -268,6 +265,23 @@ def search_operator(self, compiler, connection):
268265
269266
270267class SearchIn (SearchExpression ):
268+ """
269+ Atlas Search expression that matches documents where the field value is in a given list.
270+
271+ This expression uses the **in** operator to match documents whose field
272+ contains a value from the provided array of values.
273+
274+ Example:
275+ SearchIn("status", ["pending", "approved", "rejected"])
276+
277+ Args:
278+ path: The document path to match against (as string or expression).
279+ value: A list of values to check for membership.
280+ score: Optional expression to adjust the relevance score.
281+
282+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/in/
283+ """
284+
271285 def __init__ (self , path , value , score = None ):
272286 self .path = cast_as_field (path )
273287 self .value = cast_as_value (value )
@@ -297,7 +311,7 @@ class SearchPhrase(SearchExpression):
297311 """
298312 Atlas Search expression that matches a phrase in the specified field.
299313
300- This expression uses the **phrase** operator to search for exact or near- exact
314+ This expression uses the **phrase** operator to search for exact or near exact
301315 sequences of terms. It supports optional slop (word distance) and synonym sets.
302316
303317 Example:
@@ -310,10 +324,7 @@ class SearchPhrase(SearchExpression):
310324 synonyms: Optional name of a synonym mapping defined in the Atlas index.
311325 score: Optional expression to modify the relevance score.
312326
313- Notes:
314- * The field must be mapped as `"type": "string"` with appropriate analyzers.
315- * Slop allows flexibility in word positioning, like `"quick brown fox"`
316- matching `"quick fox"` if `slop=1`.
327+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/phrase/
317328 """
318329
319330 def __init__ (self , path , query , slop = None , synonyms = None , score = None ):
@@ -363,9 +374,7 @@ class SearchQueryString(SearchExpression):
363374 query: The Lucene-style query string.
364375 score: Optional expression to modify the relevance score.
365376
366- Notes:
367- * The query string syntax must conform to Atlas Search rules.
368- * This operator is powerful but can be harder to validate or sanitize.
377+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/queryString/
369378 """
370379
371380 def __init__ (self , path , query , score = None ):
@@ -411,9 +420,7 @@ class SearchRange(SearchExpression):
411420 gte: Optional inclusive lower bound (`>=`).
412421 score: Optional expression to modify the relevance score.
413422
414- Notes:
415- * At least one of `lt`, `lte`, `gt`, or `gte` must be provided.
416- * The field must be mapped in the Atlas Search index as a comparable type.
423+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/range/
417424 """
418425
419426 def __init__ (self , path , lt = None , lte = None , gt = None , gte = None , score = None ):
@@ -467,10 +474,7 @@ class SearchRegex(SearchExpression):
467474 allow_analyzed_field: Whether to allow matching against analyzed fields (default is False).
468475 score: Optional expression to modify the relevance score.
469476
470- Notes:
471- * Regular expressions must follow JavaScript regex syntax.
472- * By default, the field must be mapped as `"analyzer": "keyword"`
473- unless `allow_analyzed_field=True`.
477+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/regex/
474478 """
475479
476480 def __init__ (self , path , query , allow_analyzed_field = None , score = None ):
@@ -519,9 +523,7 @@ class SearchText(SearchExpression):
519523 synonyms: Optional name of a synonym mapping defined in the Atlas index.
520524 score: Optional expression to adjust relevance scoring.
521525
522- Notes:
523- * The target field must be indexed for full-text search in Atlas.
524- * Fuzzy matching helps match terms with minor typos or variations.
526+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/text/
525527 """
526528
527529 def __init__ (self , path , query , fuzzy = None , match_criteria = None , synonyms = None , score = None ):
@@ -574,11 +576,7 @@ class SearchWildcard(SearchExpression):
574576 allow_analyzed_field: Whether to allow matching against analyzed fields (default is False).
575577 score: Optional expression to modify the relevance score.
576578
577- Notes:
578- * Wildcard patterns follow standard syntax, where `*` matches any sequence of characters
579- and `?` matches a single character.
580- * By default, the field should be keyword or unanalyzed
581- unless `allow_analyzed_field=True`.
579+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/
582580 """
583581
584582 def __init__ (self , path , query , allow_analyzed_field = None , score = None ):
@@ -625,9 +623,7 @@ class SearchGeoShape(SearchExpression):
625623 geometry: The GeoJSON geometry to compare against.
626624 score: Optional expression to modify the relevance score.
627625
628- Notes:
629- * The field must be indexed as a geo shape type in Atlas Search.
630- * Geometry must conform to GeoJSON specification.
626+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/
631627 """
632628
633629 def __init__ (self , path , relation , geometry , score = None ):
@@ -674,9 +670,7 @@ class SearchGeoWithin(SearchExpression):
674670 geo_object: The GeoJSON geometry defining the boundary.
675671 score: Optional expression to adjust the relevance score.
676672
677- Notes:
678- * The geo field must be indexed appropriately in the Atlas Search index.
679- * The geometry must follow GeoJSON format.
673+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/
680674 """
681675
682676 def __init__ (self , path , kind , geo_object , score = None ):
@@ -719,9 +713,7 @@ class SearchMoreLikeThis(SearchExpression):
719713 documents: A list of example documents or expressions to find similar documents.
720714 score: Optional expression to modify the relevance scoring.
721715
722- Notes:
723- * The documents should be representative examples to base similarity on.
724- * Supports various field types depending on the Atlas Search configuration.
716+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/
725717 """
726718
727719 def __init__ (self , documents , score = None ):
@@ -774,9 +766,7 @@ class CompoundExpression(SearchExpression):
774766 score: Optional expression to adjust scoring.
775767 minimum_should_match: Minimum number of `should` clauses that must match.
776768
777- Notes:
778- * This is the most flexible way to build complex Atlas Search queries.
779- * Supports nesting of expressions to any depth.
769+ Reference: https://www.mongodb.com/docs/atlas/atlas-search/compound/
780770 """
781771
782772 def __init__ (
@@ -859,10 +849,6 @@ class CombinedSearchExpression(SearchExpression):
859849 lhs: The left-hand search expression.
860850 operator: The boolean operator as a string (e.g., "and", "or", "not").
861851 rhs: The right-hand search expression.
862-
863- Notes:
864- * The operator must be supported by MongoDB Atlas Search boolean logic.
865- * This class enables building complex nested search queries.
866852 """
867853
868854 def __init__ (self , lhs , operator , rhs ):
@@ -917,10 +903,7 @@ class SearchVector(SearchExpression):
917903 exact: Optional flag to enforce exact matching.
918904 filter: Optional filter expression to narrow candidate documents.
919905
920- Notes:
921- * The vector field must be indexed as a vector type in Atlas Search.
922- * Parameters like `num_candidates` and `exact` control search
923- performance and accuracy trade-offs.
906+ Reference: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/
924907 """
925908
926909 def __init__ (
0 commit comments