Skip to content

start_search

start_search(
    workspace_name: WorkspaceName,
    query_statement: SearchQueryStatement,
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    search_type: Optional[SearchType] = None,
    search_filters: Optional[SearchFilters] = None,
    group_id: Optional[GroupId] = None,
) -> StartSearchResponse

Starts an asynchronous search over the data in a workspace. The search runs in the background; the response returns immediately with a searchId and an initial status of QUEUED. Use DescribeSearch to poll for completion and GetSearchResults to retrieve the results once the search reaches SUCCEEDED. The request is idempotent on clientToken: repeating a call with the same token returns the original search instead of starting a new one.

Parameters:

  • workspace_name (WorkspaceName) –

    The name of the workspace whose data is searched.

  • query_statement (SearchQueryStatement) –

    The natural-language query describing the data to search for.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier you provide to ensure the request is idempotent. Repeating a StartSearch call with the same clientToken returns the original search rather than starting a new one. If omitted, the SDK autogenerates one.

  • search_type (Optional[SearchType], default: None ) –

    The search strategy to use. Defaults to QUICK when omitted.

  • search_filters (Optional[SearchFilters], default: None ) –

    Optional filters that restrict the search to a subset of the workspace's data.

  • group_id (Optional[GroupId], default: None ) –

    An optional caller-supplied identifier used to group related searches together.

Raises:

  • AccessDeniedException –

    Access is denied.

  • ConflictingOperationException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.

  • InternalFailureException –

    IoT SiteWise can't process your request right now. Try again later.

  • InvalidRequestException –

    The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.

  • LimitExceededException –

    You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • ResourceNotFoundException –

    The requested resource can't be found.

  • ThrottlingException –

    Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_iotsitewise/_services/io_t_site_wise.py
def start_search(
    self,
    workspace_name: "capo_iotsitewise.types.workspace_name.WorkspaceName",
    query_statement: "capo_iotsitewise.types.search_query_statement.SearchQueryStatement",
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    client_token: Optional[
        "capo_iotsitewise.types.client_token.ClientToken"
    ] = None,
    search_type: Optional["capo_iotsitewise.types.search_type.SearchType"] = None,
    search_filters: Optional[
        "capo_iotsitewise.types.search_filters.SearchFilters"
    ] = None,
    group_id: Optional["capo_iotsitewise.types.group_id.GroupId"] = None,
) -> "capo_iotsitewise.types.start_search_response.StartSearchResponse":
    """<p>Starts an asynchronous search over the data in a workspace. The search runs in the background; the response returns immediately with a <code>searchId</code> and an initial status of <code>QUEUED</code>. Use <code>DescribeSearch</code> to poll for completion and <code>GetSearchResults</code> to retrieve the results once the search reaches <code>SUCCEEDED</code>. The request is idempotent on <code>clientToken</code>: repeating a call with the same token returns the original search instead of starting a new one.</p>

    Args:
        workspace_name: <p>The name of the workspace whose data is searched.</p>
        query_statement: <p>The natural-language query describing the data to search for.</p>
        client_token: <p>A unique, case-sensitive identifier you provide to ensure the request is idempotent. Repeating a StartSearch call with the same <code>clientToken</code> returns the original search rather than starting a new one. If omitted, the SDK autogenerates one.</p>
        search_type: <p>The search strategy to use. Defaults to <code>QUICK</code> when omitted.</p>
        search_filters: <p>Optional filters that restrict the search to a subset of the workspace's data.</p>
        group_id: <p>An optional caller-supplied identifier used to group related searches together.</p>

    Raises:
        capo_iotsitewise.errors.access_denied_exception.AccessDeniedException: <p>Access is denied.</p>
        capo_iotsitewise.errors.conflicting_operation_exception.ConflictingOperationException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.</p>
        capo_iotsitewise.errors.internal_failure_exception.InternalFailureException: <p>IoT SiteWise can't process your request right now. Try again later.</p>
        capo_iotsitewise.errors.invalid_request_exception.InvalidRequestException: <p>The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.</p>
        capo_iotsitewise.errors.limit_exceeded_exception.LimitExceededException: <p>You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource can't be found.</p>
        capo_iotsitewise.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_iotsitewise.types.start_search_request.StartSearchRequest]",
    ) -> OperationResponse[
        "capo_iotsitewise.types.start_search_response.StartSearchResponse"
    ]:
        import capo_iotsitewise._operations.aws_io_t_site_wise.start_search

        output, http_response = (
            capo_iotsitewise._operations.aws_io_t_site_wise.start_search.start_search(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_iotsitewise.types.start_search_request.StartSearchRequest",
    ) -> dict[str, Any]:
        import capo_iotsitewise.types.start_search_request

        return capo_iotsitewise.types.start_search_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StartSearch", redact_input=_redact_input),
    )
    input_: capo_iotsitewise.types.start_search_request.StartSearchRequest = {
        "workspace_name": workspace_name,
        "query_statement": query_statement,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if search_type is not None:
        input_["search_type"] = search_type
    if search_filters is not None:
        input_["search_filters"] = search_filters
    if group_id is not None:
        input_["group_id"] = group_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output