@@ -167,6 +167,35 @@ def _filter(
167167 limit : Optional [int ] = None ,
168168 only_id : bool = False ,
169169 ) -> 'DocumentArray' :
170+ """Returns a subset of documents by filtering by the given query.
171+ The query language we provide now is following the
172+ [MongoDB](https://docs.mongodb.com/manual/reference/operator/query/) query language. For example::
173+
174+ >>> docs._filter({'text': {'$eq': 'hello'}})
175+
176+ The above will return a `DocumentArray` in which each document has doc.text == 'hello'. And we also support
177+ placeholder format by using the following syntax::
178+
179+ >>> docs._filter({'text': {'$eq': '{tags__name}'}})
180+
181+ will return a `DocumentArray` in which each document has doc.text == doc.tags['name'].
182+
183+ Now, only the subset of MongoDB's query operators are supported:
184+ - `$eq` - Equal to (number, string)
185+ - `$ne` - Not equal to (number, string)
186+ - `$gt` - Greater than (number)
187+ - `$gte` - Greater than or equal to (number)
188+ - `$lt` - Less than (number)
189+ - `$lte` - Less than or equal to (number)
190+ - `$in` - Included in an array
191+ - `$nin` - Not included in an array
192+ - `$regex` - Match a specified regular expression
193+
194+ :param query: the input query dictionary.
195+ :param limit: the maximum number of matches, when not given defaults to 20.
196+ :param only_id: if set, then returning documents will only contain ``id``
197+ :return: a `DocumentArray` containing the `Document` objects for matching with the query.
198+ """
170199 from ... import DocumentArray
171200 from ..queryset import QueryParser
172201
0 commit comments