Skip to content

search_users async

search_users(
    collection_id: CollectionId,
    *,
    config_overrides: Optional[AsyncRekognitionClientConfig] = None,
    user_id: Optional[UserId] = None,
    face_id: Optional[FaceId] = None,
    user_match_threshold: Optional[Percent] = None,
    max_users: Optional[MaxUserResults] = None,
) -> SearchUsersResponse

Searches for UserIDs within a collection based on a FaceId or UserId. This API can be used to find the closest UserID (with a highest similarity) to associate a face. The request must be provided with either FaceId or UserId. The operation returns an array of UserID that match the FaceId or UserId, ordered by similarity score with the highest similarity first.

Parameters:

  • collection_id (CollectionId) –

    The ID of an existing collection containing the UserID, used with a UserId or FaceId. If a FaceId is provided, UserId isn’t required to be present in the Collection.

  • user_id (Optional[UserId], default: None ) –

    ID for the existing User.

  • face_id (Optional[FaceId], default: None ) –

    ID for the existing face.

  • user_match_threshold (Optional[Percent], default: None ) –

    Optional value that specifies the minimum confidence in the matched UserID to return. Default value of 80.

  • max_users (Optional[MaxUserResults], default: None ) –

    Maximum number of identities to return.

Raises:

Examples:

SearchUsers Searches for UserIDs within a collection based on a FaceId or UserId.

>>> await client.search_users(collection_id='MyCollection', user_id='DemoUser', max_users=2, user_match_threshold=70)
Source code in docs_src/capo_rekognition/_services/async_rekognition.py
async def search_users(
    self,
    collection_id: "capo_rekognition.types.collection_id.CollectionId",
    *,
    config_overrides: Optional[AsyncRekognitionClientConfig] = None,
    user_id: Optional["capo_rekognition.types.user_id.UserId"] = None,
    face_id: Optional["capo_rekognition.types.face_id.FaceId"] = None,
    user_match_threshold: Optional["capo_rekognition.types.percent.Percent"] = None,
    max_users: Optional[
        "capo_rekognition.types.max_user_results.MaxUserResults"
    ] = None,
) -> "capo_rekognition.types.search_users_response.SearchUsersResponse":
    """<p>Searches for UserIDs within a collection based on a <code>FaceId</code> or <code>UserId</code>. This API can be used to find the closest UserID (with a highest similarity) to associate a face. The request must be provided with either <code>FaceId</code> or <code>UserId</code>. The operation returns an array of UserID that match the <code>FaceId</code> or <code>UserId</code>, ordered by similarity score with the highest similarity first. </p>

    Args:
        collection_id: <p>The ID of an existing collection containing the UserID, used with a UserId or FaceId. If a FaceId is provided, UserId isn’t required to be present in the Collection.</p>
        user_id: <p>ID for the existing User.</p>
        face_id: <p>ID for the existing face.</p>
        user_match_threshold: <p>Optional value that specifies the minimum confidence in the matched UserID to return. Default value of 80.</p>
        max_users: <p>Maximum number of identities to return.</p>

    Raises:
        capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
        capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
        capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
        capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
        capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
        capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
        capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        SearchUsers
        Searches for UserIDs within a collection based on a FaceId or UserId.

        >>> await client.search_users(collection_id='MyCollection', user_id='DemoUser', max_users=2, user_match_threshold=70)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rekognition.types.search_users_request.SearchUsersRequest]",
    ) -> AsyncOperationResponse[
        "capo_rekognition.types.search_users_response.SearchUsersResponse"
    ]:
        import capo_rekognition._operations.rekognition_service.search_users

        (
            output,
            http_response,
        ) = await capo_rekognition._operations.rekognition_service.search_users.async_search_users(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SearchUsers")
    )
    input_: capo_rekognition.types.search_users_request.SearchUsersRequest = {
        "collection_id": collection_id
    }
    if user_id is not None:
        input_["user_id"] = user_id
    if face_id is not None:
        input_["face_id"] = face_id
    if user_match_threshold is not None:
        input_["user_match_threshold"] = user_match_threshold
    if max_users is not None:
        input_["max_users"] = max_users

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output