@@ -327,29 +327,29 @@ def search(
327327 from chromadb.execution.expression import (
328328 Search, Key, K, Knn, Val
329329 )
330-
330+
331331 # Note: K is an alias for Key, so K.DOCUMENT == Key.DOCUMENT
332332 search = (Search()
333333 .where((K("category") == "science") & (K("score") > 0.5))
334334 .rank(Knn(query=[0.1, 0.2, 0.3]) * 0.8 + Val(0.5) * 0.2)
335335 .limit(10, offset=0)
336336 .select(K.DOCUMENT, K.SCORE, "title"))
337-
337+
338338 # Direct construction
339339 from chromadb.execution.expression import (
340340 Search, Eq, And, Gt, Knn, Limit, Select, Key
341341 )
342-
342+
343343 search = Search(
344344 where=And([Eq("category", "science"), Gt("score", 0.5)]),
345345 rank=Knn(query=[0.1, 0.2, 0.3]),
346346 limit=Limit(offset=0, limit=10),
347347 select=Select(keys={Key.DOCUMENT, Key.SCORE, "title"})
348348 )
349-
349+
350350 # Single search
351351 result = collection.search(search)
352-
352+
353353 # Multiple searches at once
354354 searches = [
355355 Search().where(K("type") == "article").rank(Knn(query=[0.1, 0.2])),
@@ -490,3 +490,64 @@ def delete(
490490 tenant = self .tenant ,
491491 database = self .database ,
492492 )
493+
494+ def create_task (
495+ self ,
496+ name : str ,
497+ operator_id : str ,
498+ output_collection : str ,
499+ params : Optional [str ] = None ,
500+ ) -> tuple [bool , str ]:
501+ """Create a recurring task that processes this collection.
502+
503+ Args:
504+ name: Unique name for this task instance
505+ operator_id: Built-in operator identifier (e.g., "record_counter")
506+ output_collection: Name of the collection where task output will be stored
507+ params: Optional JSON string with operator-specific parameters
508+
509+ Returns:
510+ tuple: (success: bool, task_id: str)
511+
512+ Example:
513+ >>> success, task_id = collection.create_task(
514+ ... name="count_docs",
515+ ... operator_id="record_counter",
516+ ... output_collection="doc_counts",
517+ ... params=None
518+ ... )
519+ """
520+ return self ._client .create_task (
521+ task_name = name ,
522+ operator_id = operator_id ,
523+ input_collection_name = self .name ,
524+ output_collection_name = output_collection ,
525+ params = params ,
526+ tenant = self .tenant ,
527+ database = self .database ,
528+ )
529+
530+ def remove_task (
531+ self ,
532+ name : str ,
533+ delete_output : bool = False ,
534+ ) -> bool :
535+ """Delete a task and prevent any further runs.
536+
537+ Args:
538+ name: Name of the task to remove
539+ delete_output: Whether to also delete the output collection. Defaults to False.
540+
541+ Returns:
542+ bool: True if successful
543+
544+ Example:
545+ >>> success = collection.remove_task("count_docs", delete_output=True)
546+ """
547+ return self ._client .remove_task (
548+ task_name = name ,
549+ input_collection_name = self .name ,
550+ delete_output = delete_output ,
551+ tenant = self .tenant ,
552+ database = self .database ,
553+ )
0 commit comments