MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / scan

Method scan

couchbase/collection.py:1065–1113  ·  view source on GitHub ↗

Execute a key-value range scan operation from the collection. .. note:: Use this API for low concurrency batch queries where latency is not a critical as the system may have to scan a lot of documents to find the matching documents. For low latency range queries, it

(self,
             scan_type,  # type: ScanType
             *opts,  # type: ScanOptions
             **kwargs,  # type: Dict[str, Any]
             )

Source from the content-addressed store, hash-verified

1063 return self._impl.mutate_in(req, obs_handler)
1064
1065 def scan(self,
1066 scan_type, # type: ScanType
1067 *opts, # type: ScanOptions
1068 **kwargs, # type: Dict[str, Any]
1069 ) -> ScanResultIterable:
1070 """Execute a key-value range scan operation from the collection.
1071
1072 .. note::
1073 Use this API for low concurrency batch queries where latency is not a critical as the system may have to scan a lot of documents to find the matching documents.
1074 For low latency range queries, it is recommended that you use SQL++ with the necessary indexes.
1075
1076 Args:
1077 scan_type (:class:`~couchbase.kv_range_scan.ScanType`): Either a :class:`~couchbase.kv_range_scan.RangeScan`,
1078 :class:`~couchbase.kv_range_scan.PrefixScan` or
1079 :class:`~couchbase.kv_range_scan.SamplingScan` instance.
1080 opts (:class:`~couchbase.options.ScanOptions`): Optional parameters for this operation.
1081 **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to
1082 override provided :class:`~couchbase.options.ScanOptions`
1083
1084 Raises:
1085 :class:`~couchbase.exceptions.InvalidArgumentException`: If scan_type is not either a RangeScan or SamplingScan instance.
1086 :class:`~couchbase.exceptions.InvalidArgumentException`: If sort option is provided and is incorrect type.
1087 :class:`~couchbase.exceptions.InvalidArgumentException`: If consistent_with option is provided and is not a
1088
1089 Returns:
1090 :class:`~couchbase.result.ScanResultIterable`: An instance of :class:`~couchbase.result.ScanResultIterable`.
1091
1092 Examples:
1093
1094 Simple range scan operation::
1095
1096 from couchbase.kv_range_scan import RangeScan
1097 from couchbase.options import ScanOptions
1098
1099 # ... other code ...
1100
1101 bucket = cluster.bucket('travel-sample')
1102 collection = bucket.scope('inventory').collection('airline')
1103
1104 scan_type = RangeScan(ScanTerm('airline-00'), ScanTerm('airline-99'))
1105 scan_iter = collection.scan(scan_type, ScanOptions(ids_only=True))
1106
1107 for res in scan_iter:
1108 print(res)
1109
1110
1111 """ # noqa: E501
1112 req = self._impl.request_builder.build_range_scan_request(self._impl.connection, scan_type, *opts, **kwargs)
1113 return self._impl.range_scan(req)
1114
1115 def binary(self) -> BinaryCollection:
1116 """Creates a BinaryCollection instance, allowing access to various binary operations

Calls 2

range_scanMethod · 0.45