startSearch method
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.
May throw AccessDeniedException.
May throw ConflictingOperationException.
May throw InternalFailureException.
May throw InvalidRequestException.
May throw LimitExceededException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter queryStatement :
The natural-language query describing the data to search for.
Parameter workspaceName :
The name of the workspace whose data is searched.
Parameter clientToken :
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.
Parameter groupId :
An optional caller-supplied identifier used to group related searches
together.
Parameter searchFilters :
Optional filters that restrict the search to a subset of the workspace's
data.
Parameter searchType :
The search strategy to use. Defaults to QUICK when omitted.
Implementation
Future<StartSearchResponse> startSearch({
required String queryStatement,
required String workspaceName,
String? clientToken,
String? groupId,
SearchFilters? searchFilters,
SearchType? searchType,
}) async {
final $payload = <String, dynamic>{
'queryStatement': queryStatement,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (groupId != null) 'groupId': groupId,
if (searchFilters != null) 'searchFilters': searchFilters,
if (searchType != null) 'searchType': searchType.value,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/workspaces/${Uri.encodeComponent(workspaceName)}/searches',
hostPrefix: 'data.',
exceptionFnMap: _exceptionFns,
);
return StartSearchResponse.fromJson(response);
}