Discovery

public class Discovery

IBM Watson™ Discovery is a cognitive search and content analytics engine that you can add to applications to identify patterns, trends and actionable insights to drive better decision-making. Securely unify structured and unstructured data with pre-enriched content, and use a simplified query language to eliminate the need for manual filtering of results.

  • The base URL to use when contacting the service.

    Declaration

    Swift

    public var serviceURL: String?
  • Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is 2019-04-30.

    Declaration

    Swift

    public var version: String
  • Service identifiers

    Declaration

    Swift

    public static let defaultServiceName: String
  • The default HTTP headers for all requests to the service.

    Declaration

    Swift

    public var defaultHeaders: [String : String]
  • Undocumented

    Declaration

    Swift

    public let authenticator: Authenticator
  • Create a Discovery object.

    If an authenticator is not supplied, the initializer will retrieve credentials from the environment or a local credentials file and construct an appropriate authenticator using these credentials. The credentials file can be downloaded from your service instance on IBM Cloud as ibm-credentials.env. Make sure to add the credentials file to your project so that it can be loaded at runtime.

    If an authenticator is not supplied and credentials are not available in the environment or a local credentials file, initialization will fail by throwing an exception. In that case, try another initializer that directly passes in the credentials.

    • serviceName: String = defaultServiceName
  • Create a Discovery object.

    Declaration

    Swift

    public init(version: String, authenticator: Authenticator)

    Parameters

    version

    Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is 2019-04-30.

    authenticator

    The Authenticator object used to authenticate requests to the service

  • Allow network requests to a server without verification of the server certificate. IMPORTANT: This should ONLY be used if truly intended, as it is unsafe otherwise.

    Declaration

    Swift

    public func disableSSLVerification()
  • Create an environment.

    Creates a new environment for private data. An environment must be created before collections can be created. Note: You can create only one environment for private data per service instance. An attempt to create another environment results in an error.

    Declaration

    Swift

    public func createEnvironment(
        name: String,
        description: String? = nil,
        size: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Environment>?, WatsonError?) -> Void)

    Parameters

    name

    Name that identifies the environment.

    description

    Description of the environment.

    size

    Size of the environment. In the Lite plan the default and only accepted value is LT, in all other plans the default is S.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List environments.

    List existing environments for the service instance.

    Declaration

    Swift

    public func listEnvironments(
        name: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ListEnvironmentsResponse>?, WatsonError?) -> Void)

    Parameters

    name

    Show only the environment with the given name.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get environment info.

    Declaration

    Swift

    public func getEnvironment(
        environmentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Environment>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Update an environment.

    Updates an environment. The environment’s name and description parameters can be changed. You must specify a name for the environment.

    Declaration

    Swift

    public func updateEnvironment(
        environmentID: String,
        name: String? = nil,
        description: String? = nil,
        size: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Environment>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    Name that identifies the environment.

    description

    Description of the environment.

    size

    Size that the environment should be increased to. Environment size cannot be modified when using a Lite plan. Environment size can only increased and not decreased.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete environment.

    Declaration

    Swift

    public func deleteEnvironment(
        environmentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DeleteEnvironmentResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List fields across collections.

    Gets a list of the unique fields (and their types) stored in the indexes of the specified collections.

    Declaration

    Swift

    public func listFields(
        environmentID: String,
        collectionIDs: [String],
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ListCollectionFieldsResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionIDs

    A comma-separated list of collection IDs to be queried against.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Add configuration.

    Creates a new configuration. If the input configuration contains the configuration_id, created, or updated properties, then they are ignored and overridden by the system, and an error is not returned so that the overridden fields do not need to be removed when copying a configuration. The configuration can contain unrecognized JSON fields. Any such fields are ignored and do not generate an error. This makes it easier to use newer configuration files with older versions of the API and the service. It also makes it possible for the tooling to add additional metadata and information to the configuration.

    Declaration

    Swift

    public func createConfiguration(
        environmentID: String,
        name: String,
        description: String? = nil,
        conversions: Conversions? = nil,
        enrichments: [Enrichment]? = nil,
        normalizations: [NormalizationOperation]? = nil,
        source: Source? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Configuration>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    The name of the configuration.

    description

    The description of the configuration, if available.

    conversions

    Document conversion settings.

    enrichments

    An array of document enrichment settings for the configuration.

    normalizations

    Defines operations that can be used to transform the final output JSON into a normalized form. Operations are executed in the order that they appear in the array.

    source

    Object containing source parameters for the configuration.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List configurations.

    Lists existing configurations for the service instance.

    Declaration

    Swift

    public func listConfigurations(
        environmentID: String,
        name: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ListConfigurationsResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    Find configurations with the given name.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get configuration details.

    Declaration

    Swift

    public func getConfiguration(
        environmentID: String,
        configurationID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Configuration>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    configurationID

    The ID of the configuration.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Update a configuration.

    Replaces an existing configuration.

    • Completely replaces the original configuration.
    • The configuration_id, updated, and created fields are accepted in the request, but they are ignored, and an error is not generated. It is also acceptable for users to submit an updated configuration with none of the three properties.
    • Documents are processed with a snapshot of the configuration as it was at the time the document was submitted to be ingested. This means that already submitted documents will not see any updates made to the configuration.

    Declaration

    Swift

    public func updateConfiguration(
        environmentID: String,
        configurationID: String,
        name: String,
        description: String? = nil,
        conversions: Conversions? = nil,
        enrichments: [Enrichment]? = nil,
        normalizations: [NormalizationOperation]? = nil,
        source: Source? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Configuration>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    configurationID

    The ID of the configuration.

    name

    The name of the configuration.

    description

    The description of the configuration, if available.

    conversions

    Document conversion settings.

    enrichments

    An array of document enrichment settings for the configuration.

    normalizations

    Defines operations that can be used to transform the final output JSON into a normalized form. Operations are executed in the order that they appear in the array.

    source

    Object containing source parameters for the configuration.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete a configuration.

    The deletion is performed unconditionally. A configuration deletion request succeeds even if the configuration is referenced by a collection or document ingestion. However, documents that have already been submitted for processing continue to use the deleted configuration. Documents are always processed with a snapshot of the configuration as it existed at the time the document was submitted.

    Declaration

    Swift

    public func deleteConfiguration(
        environmentID: String,
        configurationID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DeleteConfigurationResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    configurationID

    The ID of the configuration.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create a collection.

    Declaration

    Swift

    public func createCollection(
        environmentID: String,
        name: String,
        description: String? = nil,
        configurationID: String? = nil,
        language: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Collection>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    The name of the collection to be created.

    description

    A description of the collection.

    configurationID

    The ID of the configuration in which the collection is to be created.

    language

    The language of the documents stored in the collection, in the form of an ISO 639-1 language code.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List collections.

    Lists existing collections for the service instance.

    Declaration

    Swift

    public func listCollections(
        environmentID: String,
        name: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ListCollectionsResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    Find collections with the given name.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get collection details.

    Declaration

    Swift

    public func getCollection(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Collection>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Update a collection.

    Declaration

    Swift

    public func updateCollection(
        environmentID: String,
        collectionID: String,
        name: String,
        description: String? = nil,
        configurationID: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Collection>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    name

    The name of the collection.

    description

    A description of the collection.

    configurationID

    The ID of the configuration in which the collection is to be updated.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete a collection.

    Declaration

    Swift

    public func deleteCollection(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DeleteCollectionResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List collection fields.

    Gets a list of the unique fields (and their types) stored in the index.

    Declaration

    Swift

    public func listCollectionFields(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<ListCollectionFieldsResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get the expansion list.

    Returns the current expansion list for the specified collection. If an expansion list is not specified, an object with empty expansion arrays is returned.

    Declaration

    Swift

    public func listExpansions(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Expansions>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create or update expansion list.

    Create or replace the Expansion list for this collection. The maximum number of expanded terms per collection is 500. The current expansion list is replaced with the uploaded content.

    Declaration

    Swift

    public func createExpansions(
        environmentID: String,
        collectionID: String,
        expansions: [Expansion],
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Expansions>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    expansions

    An array of query expansion definitions. Each object in the expansions array represents a term or set of terms that will be expanded into other terms. Each expansion object can be configured as bidirectional or unidirectional. Bidirectional means that all terms are expanded to all other terms in the object. Unidirectional means that a set list of terms can be expanded into a second list of terms. To create a bi-directional expansion specify an expanded_terms array. When found in a query, all items in the expanded_terms array are then expanded to the other items in the same array. To create a uni-directional expansion, specify both an array of input_terms and an array of expanded_terms. When items in the input_terms array are present in a query, they are expanded using the items listed in the expanded_terms array.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete the expansion list.

    Remove the expansion information for this collection. The expansion list must be deleted to disable query expansion for a collection.

    Declaration

    Swift

    public func deleteExpansions(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get tokenization dictionary status.

    Returns the current status of the tokenization dictionary for the specified collection.

    Declaration

    Swift

    public func getTokenizationDictionaryStatus(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TokenDictStatusResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create tokenization dictionary.

    Upload a custom tokenization dictionary to use with the specified collection.

    Declaration

    Swift

    public func createTokenizationDictionary(
        environmentID: String,
        collectionID: String,
        tokenizationRules: [TokenDictRule]? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TokenDictStatusResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    tokenizationRules

    An array of tokenization rules. Each rule contains, the original text string, component tokens, any alternate character set readings, and which part_of_speech the text is from.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete tokenization dictionary.

    Delete the tokenization dictionary from the collection.

    Declaration

    Swift

    public func deleteTokenizationDictionary(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get stopword list status.

    Returns the current status of the stopword list for the specified collection.

    Declaration

    Swift

    public func getStopwordListStatus(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TokenDictStatusResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create stopword list.

    Upload a custom stopword list to use with the specified collection.

    Declaration

    Swift

    public func createStopwordList(
        environmentID: String,
        collectionID: String,
        stopwordFile: Data,
        stopwordFilename: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TokenDictStatusResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    stopwordFile

    The content of the stopword list to ingest.

    stopwordFilename

    The filename for stopwordFile.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete a custom stopword list.

    Delete a custom stopword list from the collection. After a custom stopword list is deleted, the default list is used for the collection.

    Declaration

    Swift

    public func deleteStopwordList(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Add a document.

    Add a document to a collection with optional metadata.

    • The version query parameter is still required.
    • The user must provide document content, metadata, or both. If the request is missing both document content and metadata, it is rejected.
    • The user can set the Content-Type parameter on the file part to indicate the media type of the document. If the Content-Type parameter is missing or is one of the generic media types (for example, application/octet-stream), then the service attempts to automatically detect the document’s media type.
    • The following field names are reserved and will be filtered out if present after normalization: id, score, highlight, and any field with the prefix of: _, +, or -
    • Fields with empty name values after normalization are filtered out before indexing.
    • Fields containing the following characters after normalization are filtered out before indexing: # and , Note: Documents can be added with a specific document_id by using the _/v1/environments/{environment_id}/collections/{collection_id}/documents method.

    Declaration

    Swift

    public func addDocument(
        environmentID: String,
        collectionID: String,
        file: Data? = nil,
        filename: String? = nil,
        fileContentType: String? = nil,
        metadata: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DocumentAccepted>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    file

    The content of the document to ingest. The maximum supported file size when adding a file to a collection is 50 megabytes, the maximum supported file size when testing a configuration is 1 megabyte. Files larger than the supported size are rejected.

    filename

    The filename for file.

    fileContentType

    The content type of file.

    metadata

    The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected. Example: { "Creator": "Johnny Appleseed", "Subject": "Apples" }.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get document details.

    Fetch status details about a submitted document. Note: this operation does not return the document itself. Instead, it returns only the document’s processing status and any notices (warnings or errors) that were generated when the document was ingested. Use the query API to retrieve the actual document content.

    Declaration

    Swift

    public func getDocumentStatus(
        environmentID: String,
        collectionID: String,
        documentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DocumentStatus>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    documentID

    The ID of the document.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Update a document.

    Replace an existing document or add a document with a specified document_id. Starts ingesting a document with optional metadata. Note: When uploading a new document with this method it automatically replaces any document stored with the same document_id if it exists.

    Declaration

    Swift

    public func updateDocument(
        environmentID: String,
        collectionID: String,
        documentID: String,
        file: Data? = nil,
        filename: String? = nil,
        fileContentType: String? = nil,
        metadata: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DocumentAccepted>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    documentID

    The ID of the document.

    file

    The content of the document to ingest. The maximum supported file size when adding a file to a collection is 50 megabytes, the maximum supported file size when testing a configuration is 1 megabyte. Files larger than the supported size are rejected.

    filename

    The filename for file.

    fileContentType

    The content type of file.

    metadata

    The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected. Example: { "Creator": "Johnny Appleseed", "Subject": "Apples" }.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete a document.

    If the given document ID is invalid, or if the document is not found, then the a success response is returned (HTTP status code 200) with the status set to ‘deleted’.

    Declaration

    Swift

    public func deleteDocument(
        environmentID: String,
        collectionID: String,
        documentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DeleteDocumentResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    documentID

    The ID of the document.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Query a collection.

    By using this method, you can construct long queries. For details, see the Discovery documentation.

    Declaration

    Swift

    public func query(
        environmentID: String,
        collectionID: String,
        filter: String? = nil,
        query: String? = nil,
        naturalLanguageQuery: String? = nil,
        passages: Bool? = nil,
        aggregation: String? = nil,
        count: Int? = nil,
        `return`: String? = nil,
        offset: Int? = nil,
        sort: String? = nil,
        highlight: Bool? = nil,
        passagesFields: String? = nil,
        passagesCount: Int? = nil,
        passagesCharacters: Int? = nil,
        deduplicate: Bool? = nil,
        deduplicateField: String? = nil,
        similar: Bool? = nil,
        similarDocumentIDs: String? = nil,
        similarFields: String? = nil,
        bias: String? = nil,
        spellingSuggestions: Bool? = nil,
        xWatsonLoggingOptOut: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<QueryResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    filter

    A cacheable query that excludes documents that don’t mention the query content. Filter searches are better for metadata-type searches and for assessing the concepts in the data set.

    query

    A query search returns all documents in your data set with full enrichments and full text, but with the most relevant documents listed first. Use a query search when you want to find the most relevant search results.

    naturalLanguageQuery

    A natural language query that returns relevant documents by utilizing training data and natural language understanding.

    passages

    A passages query that returns the most relevant passages from the results.

    aggregation

    An aggregation search that returns an exact answer by combining query search with filters. Useful for applications to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference.

    count

    Number of results to return.

    offset

    The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results.

    sort

    A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with - for descending or + for ascending. Ascending is the default sort direction if no prefix is specified. This parameter cannot be used in the same query as the bias parameter.

    highlight

    When true, a highlight field is returned for each result which contains the fields which match the query with <em></em> tags around the matching query terms.

    passagesFields

    A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.

    passagesCount

    The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is 10. The maximum is 100.

    passagesCharacters

    The approximate number of characters that any one passage will have.

    deduplicate

    When true, and used with a Watson Discovery News collection, duplicate results (based on the contents of the title field) are removed. Duplicate comparison is limited to the current query only; offset is not considered. This parameter is currently Beta functionality.

    deduplicateField

    When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, offset is not considered. This parameter is currently Beta functionality.

    similar

    When true, results are returned based on their similarity to the document IDs specified in the similar.document_ids parameter.

    similarDocumentIDs

    A comma-separated list of document IDs to find similar documents. Tip: Include the natural_language_query parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as filter and query, are subsequently applied and reduce the scope.

    similarFields

    A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison.

    bias

    Field which the returned results will be biased against. The specified field must be either a date or number format. When a date type field is specified returned results are biased towards field values closer to the current date. When a number type field is specified, returned results are biased towards higher field values. This parameter cannot be used in the same query as the sort parameter.

    spellingSuggestions

    When true and the natural_language_query parameter is used, the natural_languge_query parameter is spell checked. The most likely correction is returned in the suggested_query field of the response (if one exists). Important: this parameter is only valid when using the Cloud Pak version of Discovery.

    xWatsonLoggingOptOut

    If true, queries are not stored in the Discovery Logs endpoint.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Query system notices.

    Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when ingesting documents and performing relevance training. See the Discovery documentation for more details on the query language.

    Declaration

    Swift

    public func queryNotices(
        environmentID: String,
        collectionID: String,
        filter: String? = nil,
        query: String? = nil,
        naturalLanguageQuery: String? = nil,
        passages: Bool? = nil,
        aggregation: String? = nil,
        count: Int? = nil,
        `return`: [String]? = nil,
        offset: Int? = nil,
        sort: [String]? = nil,
        highlight: Bool? = nil,
        passagesFields: [String]? = nil,
        passagesCount: Int? = nil,
        passagesCharacters: Int? = nil,
        deduplicateField: String? = nil,
        similar: Bool? = nil,
        similarDocumentIDs: [String]? = nil,
        similarFields: [String]? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<QueryNoticesResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    filter

    A cacheable query that excludes documents that don’t mention the query content. Filter searches are better for metadata-type searches and for assessing the concepts in the data set.

    query

    A query search returns all documents in your data set with full enrichments and full text, but with the most relevant documents listed first.

    naturalLanguageQuery

    A natural language query that returns relevant documents by utilizing training data and natural language understanding.

    passages

    A passages query that returns the most relevant passages from the results.

    aggregation

    An aggregation search that returns an exact answer by combining query search with filters. Useful for applications to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference.

    count

    Number of results to return. The maximum for the count and offset values together in any one query is 10000.

    offset

    The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the count and offset values together in any one query is 10000.

    sort

    A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with - for descending or + for ascending. Ascending is the default sort direction if no prefix is specified.

    highlight

    When true, a highlight field is returned for each result which contains the fields which match the query with <em></em> tags around the matching query terms.

    passagesFields

    A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.

    passagesCount

    The maximum number of passages to return. The search returns fewer passages if the requested total is not found.

    passagesCharacters

    The approximate number of characters that any one passage will have.

    deduplicateField

    When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, offset is not considered. This parameter is currently Beta functionality.

    similar

    When true, results are returned based on their similarity to the document IDs specified in the similar.document_ids parameter.

    similarDocumentIDs

    A comma-separated list of document IDs to find similar documents. Tip: Include the natural_language_query parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as filter and query, are subsequently applied and reduce the scope.

    similarFields

    A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Query multiple collections.

    By using this method, you can construct long queries that search multiple collection. For details, see the Discovery documentation.

    Declaration

    Swift

    public func federatedQuery(
        environmentID: String,
        collectionIDs: String,
        filter: String? = nil,
        query: String? = nil,
        naturalLanguageQuery: String? = nil,
        passages: Bool? = nil,
        aggregation: String? = nil,
        count: Int? = nil,
        `return`: String? = nil,
        offset: Int? = nil,
        sort: String? = nil,
        highlight: Bool? = nil,
        passagesFields: String? = nil,
        passagesCount: Int? = nil,
        passagesCharacters: Int? = nil,
        deduplicate: Bool? = nil,
        deduplicateField: String? = nil,
        similar: Bool? = nil,
        similarDocumentIDs: String? = nil,
        similarFields: String? = nil,
        bias: String? = nil,
        xWatsonLoggingOptOut: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<QueryResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionIDs

    A comma-separated list of collection IDs to be queried against.

    filter

    A cacheable query that excludes documents that don’t mention the query content. Filter searches are better for metadata-type searches and for assessing the concepts in the data set.

    query

    A query search returns all documents in your data set with full enrichments and full text, but with the most relevant documents listed first. Use a query search when you want to find the most relevant search results.

    naturalLanguageQuery

    A natural language query that returns relevant documents by utilizing training data and natural language understanding.

    passages

    A passages query that returns the most relevant passages from the results.

    aggregation

    An aggregation search that returns an exact answer by combining query search with filters. Useful for applications to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference.

    count

    Number of results to return.

    offset

    The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results.

    sort

    A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with - for descending or + for ascending. Ascending is the default sort direction if no prefix is specified. This parameter cannot be used in the same query as the bias parameter.

    highlight

    When true, a highlight field is returned for each result which contains the fields which match the query with <em></em> tags around the matching query terms.

    passagesFields

    A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.

    passagesCount

    The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is 10. The maximum is 100.

    passagesCharacters

    The approximate number of characters that any one passage will have.

    deduplicate

    When true, and used with a Watson Discovery News collection, duplicate results (based on the contents of the title field) are removed. Duplicate comparison is limited to the current query only; offset is not considered. This parameter is currently Beta functionality.

    deduplicateField

    When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, offset is not considered. This parameter is currently Beta functionality.

    similar

    When true, results are returned based on their similarity to the document IDs specified in the similar.document_ids parameter.

    similarDocumentIDs

    A comma-separated list of document IDs to find similar documents. Tip: Include the natural_language_query parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as filter and query, are subsequently applied and reduce the scope.

    similarFields

    A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison.

    bias

    Field which the returned results will be biased against. The specified field must be either a date or number format. When a date type field is specified returned results are biased towards field values closer to the current date. When a number type field is specified, returned results are biased towards higher field values. This parameter cannot be used in the same query as the sort parameter.

    xWatsonLoggingOptOut

    If true, queries are not stored in the Discovery Logs endpoint.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Query multiple collection system notices.

    Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when ingesting documents and performing relevance training. See the Discovery documentation for more details on the query language.

    Declaration

    Swift

    public func federatedQueryNotices(
        environmentID: String,
        collectionIDs: [String],
        filter: String? = nil,
        query: String? = nil,
        naturalLanguageQuery: String? = nil,
        aggregation: String? = nil,
        count: Int? = nil,
        `return`: [String]? = nil,
        offset: Int? = nil,
        sort: [String]? = nil,
        highlight: Bool? = nil,
        deduplicateField: String? = nil,
        similar: Bool? = nil,
        similarDocumentIDs: [String]? = nil,
        similarFields: [String]? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<QueryNoticesResponse>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionIDs

    A comma-separated list of collection IDs to be queried against.

    filter

    A cacheable query that excludes documents that don’t mention the query content. Filter searches are better for metadata-type searches and for assessing the concepts in the data set.

    query

    A query search returns all documents in your data set with full enrichments and full text, but with the most relevant documents listed first.

    naturalLanguageQuery

    A natural language query that returns relevant documents by utilizing training data and natural language understanding.

    aggregation

    An aggregation search that returns an exact answer by combining query search with filters. Useful for applications to build lists, tables, and time series. For a full list of possible aggregations, see the Query reference.

    count

    Number of results to return. The maximum for the count and offset values together in any one query is 10000.

    offset

    The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the count and offset values together in any one query is 10000.

    sort

    A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with - for descending or + for ascending. Ascending is the default sort direction if no prefix is specified.

    highlight

    When true, a highlight field is returned for each result which contains the fields which match the query with <em></em> tags around the matching query terms.

    deduplicateField

    When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, offset is not considered. This parameter is currently Beta functionality.

    similar

    When true, results are returned based on their similarity to the document IDs specified in the similar.document_ids parameter.

    similarDocumentIDs

    A comma-separated list of document IDs to find similar documents. Tip: Include the natural_language_query parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as filter and query, are subsequently applied and reduce the scope.

    similarFields

    A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get Autocomplete Suggestions.

    Returns completion query suggestions for the specified prefix. /n/n Important: this method is only valid when using the Cloud Pak version of Discovery.

    Declaration

    Swift

    public func getAutocompletion(
        environmentID: String,
        collectionID: String,
        `prefix`: String,
        field: String? = nil,
        count: Int? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Completions>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    field

    The field in the result documents that autocompletion suggestions are identified from.

    count

    The number of autocompletion suggestions to return.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List training data.

    Lists the training data for the specified collection.

    Declaration

    Swift

    public func listTrainingData(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingDataSet>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Add query to training data.

    Adds a query to the training data for this collection. The query can contain a filter and natural language query.

    Declaration

    Swift

    public func addTrainingData(
        environmentID: String,
        collectionID: String,
        naturalLanguageQuery: String? = nil,
        filter: String? = nil,
        examples: [TrainingExample]? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingQuery>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    naturalLanguageQuery

    The natural text query for the new training query.

    filter

    The filter used on the collection before the natural_language_query is applied.

    examples

    Array of training examples.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete all training data.

    Deletes all training data from a collection.

    Declaration

    Swift

    public func deleteAllTrainingData(
        environmentID: String,
        collectionID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get details about a query.

    Gets details for a specific training data query, including the query string and all examples.

    Declaration

    Swift

    public func getTrainingData(
        environmentID: String,
        collectionID: String,
        queryID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingQuery>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete a training data query.

    Removes the training data query and all associated examples from the training data set.

    Declaration

    Swift

    public func deleteTrainingData(
        environmentID: String,
        collectionID: String,
        queryID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List examples for a training data query.

    List all examples for this training data query.

    Declaration

    Swift

    public func listTrainingExamples(
        environmentID: String,
        collectionID: String,
        queryID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingExampleList>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Add example to training data query.

    Adds a example to this training data query.

    Declaration

    Swift

    public func createTrainingExample(
        environmentID: String,
        collectionID: String,
        queryID: String,
        documentID: String? = nil,
        crossReference: String? = nil,
        relevance: Int? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingExample>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    documentID

    The document ID associated with this training example.

    crossReference

    The cross reference associated with this training example.

    relevance

    The relevance of the training example.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete example for training data query.

    Deletes the example document with the given ID from the training data query.

    Declaration

    Swift

    public func deleteTrainingExample(
        environmentID: String,
        collectionID: String,
        queryID: String,
        exampleID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    exampleID

    The ID of the document as it is indexed.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Change label or cross reference for example.

    Changes the label or cross reference query for this training data example.

    Declaration

    Swift

    public func updateTrainingExample(
        environmentID: String,
        collectionID: String,
        queryID: String,
        exampleID: String,
        crossReference: String? = nil,
        relevance: Int? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingExample>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    exampleID

    The ID of the document as it is indexed.

    crossReference

    The example to add.

    relevance

    The relevance value for this example.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Get details for training data example.

    Gets the details for this training example.

    Declaration

    Swift

    public func getTrainingExample(
        environmentID: String,
        collectionID: String,
        queryID: String,
        exampleID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<TrainingExample>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    collectionID

    The ID of the collection.

    queryID

    The ID of the query used for training.

    exampleID

    The ID of the document as it is indexed.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete labeled data.

    Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID. You associate a customer ID with data by passing the X-Watson-Metadata header with a request that passes data. For more information about personal data and customer IDs, see Information security.

    Declaration

    Swift

    public func deleteUserData(
        customerID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Void>?, WatsonError?) -> Void)

    Parameters

    customerID

    The customer ID for which all data is to be deleted.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create event.

    The Events API can be used to create log entries that are associated with specific queries. For example, you can record which documents in the results set were “clicked” by a user and when that click occurred.

    Declaration

    Swift

    public func createEvent(
        type: String,
        data: EventData,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<CreateEventResponse>?, WatsonError?) -> Void)

    Parameters

    type

    The event type to be created.

    data

    Query event data object.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Search the query and event log.

    Searches the query and event log to find query sessions that match the specified criteria. Searching the logs endpoint uses the standard Discovery query syntax for the parameters that are supported.

    Declaration

    Swift

    public func queryLog(
        filter: String? = nil,
        query: String? = nil,
        count: Int? = nil,
        offset: Int? = nil,
        sort: [String]? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<LogQueryResponse>?, WatsonError?) -> Void)

    Parameters

    filter

    A cacheable query that excludes documents that don’t mention the query content. Filter searches are better for metadata-type searches and for assessing the concepts in the data set.

    query

    A query search returns all documents in your data set with full enrichments and full text, but with the most relevant documents listed first.

    count

    Number of results to return. The maximum for the count and offset values together in any one query is 10000.

    offset

    The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the count and offset values together in any one query is 10000.

    sort

    A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with - for descending or + for ascending. Ascending is the default sort direction if no prefix is specified.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Number of queries over time.

    Total number of queries using the natural_language_query parameter over a specific time window.

    Declaration

    Swift

    public func getMetricsQuery(
        startTime: Date? = nil,
        endTime: Date? = nil,
        resultType: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<MetricResponse>?, WatsonError?) -> Void)

    Parameters

    startTime

    Metric is computed from data recorded after this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    endTime

    Metric is computed from data recorded before this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    resultType

    The type of result to consider when calculating the metric.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Number of queries with an event over time.

    Total number of queries using the natural_language_query parameter that have a corresponding “click” event over a specified time window. This metric requires having integrated event tracking in your application using the Events API.

    Declaration

    Swift

    public func getMetricsQueryEvent(
        startTime: Date? = nil,
        endTime: Date? = nil,
        resultType: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<MetricResponse>?, WatsonError?) -> Void)

    Parameters

    startTime

    Metric is computed from data recorded after this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    endTime

    Metric is computed from data recorded before this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    resultType

    The type of result to consider when calculating the metric.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Number of queries with no search results over time.

    Total number of queries using the natural_language_query parameter that have no results returned over a specified time window.

    Declaration

    Swift

    public func getMetricsQueryNoResults(
        startTime: Date? = nil,
        endTime: Date? = nil,
        resultType: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<MetricResponse>?, WatsonError?) -> Void)

    Parameters

    startTime

    Metric is computed from data recorded after this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    endTime

    Metric is computed from data recorded before this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    resultType

    The type of result to consider when calculating the metric.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Percentage of queries with an associated event.

    The percentage of queries using the natural_language_query parameter that have a corresponding “click” event over a specified time window. This metric requires having integrated event tracking in your application using the Events API.

    Declaration

    Swift

    public func getMetricsEventRate(
        startTime: Date? = nil,
        endTime: Date? = nil,
        resultType: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<MetricResponse>?, WatsonError?) -> Void)

    Parameters

    startTime

    Metric is computed from data recorded after this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    endTime

    Metric is computed from data recorded before this timestamp; must be in YYYY-MM-DDThh:mm:ssZ format.

    resultType

    The type of result to consider when calculating the metric.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Most frequent query tokens with an event.

    The most frequent query tokens parsed from the natural_language_query parameter and their corresponding “click” event rate within the recording period (queries and events are stored for 30 days). A query token is an individual word or unigram within the query string.

    Declaration

    Swift

    public func getMetricsQueryTokenEvent(
        count: Int? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<MetricTokenResponse>?, WatsonError?) -> Void)

    Parameters

    count

    Number of results to return. The maximum for the count and offset values together in any one query is 10000.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List credentials.

    List all the source credentials that have been created for this service instance. Note: All credentials are sent over an encrypted connection and encrypted at rest.

    Declaration

    Swift

    public func listCredentials(
        environmentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<CredentialsList>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create credentials.

    Creates a set of credentials to connect to a remote source. Created credentials are used in a configuration to associate a collection with the remote source. Note: All credentials are sent over an encrypted connection and encrypted at rest.

    Declaration

    Swift

    public func createCredentials(
        environmentID: String,
        sourceType: String? = nil,
        credentialDetails: CredentialDetails? = nil,
        status: StatusDetails? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Credentials>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    sourceType

    The source that this credentials object connects to.

    • box indicates the credentials are used to connect an instance of Enterprise Box.
    • salesforce indicates the credentials are used to connect to Salesforce.
    • sharepoint indicates the credentials are used to connect to Microsoft SharePoint Online.
    • web_crawl indicates the credentials are used to perform a web crawl. = cloud_object_storage indicates the credentials are used to connect to an IBM Cloud Object Store.

    credentialDetails

    Object containing details of the stored credentials. Obtain credentials for your source from the administrator of the source.

    status

    Object that contains details about the status of the authentication process.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • View Credentials.

    Returns details about the specified credentials. Note: Secure credential information such as a password or SSH key is never returned and must be obtained from the source system.

    Declaration

    Swift

    public func getCredentials(
        environmentID: String,
        credentialID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Credentials>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    credentialID

    The unique identifier for a set of source credentials.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Update credentials.

    Updates an existing set of source credentials. Note: All credentials are sent over an encrypted connection and encrypted at rest.

    Declaration

    Swift

    public func updateCredentials(
        environmentID: String,
        credentialID: String,
        sourceType: String? = nil,
        credentialDetails: CredentialDetails? = nil,
        status: StatusDetails? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Credentials>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    credentialID

    The unique identifier for a set of source credentials.

    sourceType

    The source that this credentials object connects to.

    • box indicates the credentials are used to connect an instance of Enterprise Box.
    • salesforce indicates the credentials are used to connect to Salesforce.
    • sharepoint indicates the credentials are used to connect to Microsoft SharePoint Online.
    • web_crawl indicates the credentials are used to perform a web crawl. = cloud_object_storage indicates the credentials are used to connect to an IBM Cloud Object Store.

    credentialDetails

    Object containing details of the stored credentials. Obtain credentials for your source from the administrator of the source.

    status

    Object that contains details about the status of the authentication process.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete credentials.

    Deletes a set of stored credentials from your Discovery instance.

    Declaration

    Swift

    public func deleteCredentials(
        environmentID: String,
        credentialID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<DeleteCredentials>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    credentialID

    The unique identifier for a set of source credentials.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List Gateways.

    List the currently configured gateways.

    Declaration

    Swift

    public func listGateways(
        environmentID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<GatewayList>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Create Gateway.

    Create a gateway configuration to use with a remotely installed gateway.

    Declaration

    Swift

    public func createGateway(
        environmentID: String,
        name: String? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Gateway>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    name

    User-defined name.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • List Gateway Details.

    List information about the specified gateway.

    Declaration

    Swift

    public func getGateway(
        environmentID: String,
        gatewayID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<Gateway>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    gatewayID

    The requested gateway ID.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error

  • Delete Gateway.

    Delete the specified gateway configuration.

    Declaration

    Swift

    public func deleteGateway(
        environmentID: String,
        gatewayID: String,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<GatewayDelete>?, WatsonError?) -> Void)

    Parameters

    environmentID

    The ID of the environment.

    gatewayID

    The requested gateway ID.

    headers

    A dictionary of request headers to be sent with this request.

    completionHandler

    A function executed when the request completes with a successful result or error