Performs a lookup-in operation against a document, fetching individual fields or information about specific fields inside the document value. Args: key (str): The key for the document look in. spec (Iterable[:class:`~couchbase.subdocument.Spec`]): A list of
(
self,
key, # type: str
spec, # type: Iterable[Spec]
*opts, # type: LookupInOptions
**kwargs, # type: Dict[str, Any]
)
| 780 | return self._impl.unlock(req, obs_handler) |
| 781 | |
| 782 | def lookup_in( |
| 783 | self, |
| 784 | key, # type: str |
| 785 | spec, # type: Iterable[Spec] |
| 786 | *opts, # type: LookupInOptions |
| 787 | **kwargs, # type: Dict[str, Any] |
| 788 | ) -> LookupInResult: |
| 789 | """Performs a lookup-in operation against a document, fetching individual fields or information |
| 790 | about specific fields inside the document value. |
| 791 | |
| 792 | Args: |
| 793 | key (str): The key for the document look in. |
| 794 | spec (Iterable[:class:`~couchbase.subdocument.Spec`]): A list of specs describing the data to fetch |
| 795 | from the document. |
| 796 | opts (:class:`~couchbase.options.LookupInOptions`): Optional parameters for this operation. |
| 797 | **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to |
| 798 | override provided :class:`~couchbase.options.LookupInOptions` |
| 799 | |
| 800 | Returns: |
| 801 | :class:`~couchbase.result.LookupInResult`: An instance of :class:`~couchbase.result.LookupInResult`. |
| 802 | |
| 803 | Raises: |
| 804 | :class:`~couchbase.exceptions.DocumentNotFoundException`: If the key provided does not exist |
| 805 | on the server. |
| 806 | |
| 807 | Examples: |
| 808 | |
| 809 | Simple look-up in operation:: |
| 810 | |
| 811 | import couchbase.subdocument as SD |
| 812 | |
| 813 | # ... other code ... |
| 814 | |
| 815 | bucket = cluster.bucket('travel-sample') |
| 816 | collection = bucket.scope('inventory').collection('hotel') |
| 817 | |
| 818 | key = 'hotel_10025' |
| 819 | res = collection.lookup_in(key, (SD.get("geo"),)) |
| 820 | print(f'Hotel {key} coordinates: {res.content_as[dict](0)}') |
| 821 | |
| 822 | |
| 823 | Simple look-up in operation with options:: |
| 824 | |
| 825 | from datetime import timedelta |
| 826 | |
| 827 | import couchbase.subdocument as SD |
| 828 | from couchbase.options import LookupInOptions |
| 829 | |
| 830 | # ... other code ... |
| 831 | |
| 832 | key = 'hotel_10025' |
| 833 | res = collection.lookup_in(key, |
| 834 | (SD.get("geo"),), |
| 835 | LookupInOptions(timeout=timedelta(seconds=2))) |
| 836 | print(f'Hotel {key} coordinates: {res.content_as[dict](0)}') |
| 837 | |
| 838 | """ |
| 839 | instruments = self._impl.observability_instruments |
no test coverage detected