Introduction

IBM Watson™ Discovery for IBM Cloud Pak for Data 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.

Beginning with version 4.0.0, the Node SDK returns a Promise for all methods when a callback is not specified.

The package location moved to ibm-watson. It remains available at watson-developer-cloud but is not updated there. Use ibm-watson to stay up to date.

The IBM Watson Unity SDK has the following requirements.

  • The SDK requires Unity version 2018.2 or later to support TLS 1.2.
    • Set the project settings for both the Scripting Runtime Version and the Api Compatibility Level to .NET 4.x Equivalent.
    • For more information, see TLS 1.0 support.
  • The SDK does not support the WebGL projects. Change your build settings to any platform except WebGL.

For information about how to install and configure the SDK and SDK Core, see https://github.com/watson-developer-cloud/unity-sdk.

The code examples on this tab use the client library that is provided for Java.

Maven

<dependency>
  <groupId>com.ibm.watson</groupId>
  <artifactId>ibm-watson</artifactId>
  <version>7.3.0</version>
</dependency>

Gradle

compile 'com.ibm.watson:ibm-watson:7.3.0'

GitHub

The code examples on this tab use the client library that is provided for Node.js.

Installation

npm install ibm-watson

GitHub

The code examples on this tab use the client library that is provided for Python.

Installation

pip install --upgrade "ibm-watson>=3.2.0"

GitHub

The code examples on this tab use the client library that is provided for Ruby.

Installation

gem install ibm_watson

GitHub

The code examples on this tab use the client library that is provided for Go.

go get -u github.com/watson-developer-cloud/go-sdk/...

GitHub

The code examples on this tab use the client library that is provided for Swift.

Cocoapods

pod 'IBMWatsonDiscoveryV1', '~> 2.1.1'

Carthage

github "watson-developer-cloud/swift-sdk" ~> 2.1.1

Swift Package Manager

.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "2.1.1")

GitHub

The code examples on this tab use the client library that is provided for .NET Standard.

Package Manager

Install-Package IBM.Watson.Discovery.v1 -Version 3.3.0

.NET CLI

dotnet add package IBM.Watson.Discovery.v1 -version 3.3.0

PackageReference

<PackageReference Include="IBM.Watson.Discovery.v1" Version="3.3.0" />

GitHub

The code examples on this tab use the client library that is provided for Unity.

Github

Authentication

To authenticate to the API, you pass an access token in an Authorization header. The token is associated with a user name.

To authenticate to the API, you can pass either username and password credentials or an access token. Some services support only a single instance of the service and credentials. Other services support multiple instances.

  • Tokens support authenticated requests without embedding credentials in every call. If you pass a token, you maintain the token lifecycle.
  • Username and password credentials use basic authentication. However, the SDK manages the lifecycle of the tokens.

You can use the access token that is displayed in the IBM Cloud Pak for Data web client for testing and development. For production use, generate a token with the appropriate user name.

  • To find the access token in the IBM Cloud Pak for Data web client, view the details for the provisioned service instance. The details also include the service endpoint URL. For security reasons, don't use this token in production.
  • To generate an access token, call the POST preauth/validateAuth method.

To find your value for {url}, {icp4d_cluster_host} and {:port}, view the service credentials by viewing the details for the provisioned service instance in the IBM Cloud Pak for Data web client.

Generating an access token. The response includes an accessToken property.

Replace {icp4d_cluster_host} and {port} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials.

curl -u "{username}:{password}" "https://{icp4d_cluster_host}{:port}/v1/preauth/validateAuth"

Authenticating to the API. Replace {token} with your details.

curl -H "Authorization: Bearer {token}" "https://{icp4d_cluster_host}{:port}/v1/{method}"

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

ICP4DConfig config = new ICP4DConfig.Builder()
  .url("https://{icp4d_cluster_host}{:port}")
  .username("{username}")
  .password("{password}")
  .build();
Discovery discovery = new Discovery("{version}", config);
discovery.setEndPoint("{url}");

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: '{username}',
  password: '{password}',
  icp4d_url: 'https://{icp4d_cluster_host}{:port}',
  authentication_type: 'icp4d',
  url: '{url}',
});

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='{username}',
    password='{password}',
    icp4d_url='https://{icp4d_cluster_host}{:port}',
    authentication_type='icp4d',
    url='{url}'
)

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version: "{version}",
  username: "{username}",
  password: "{password}",
  icp4d_url: "https://{icp4d_cluster_host}{:port}",
  authentication_type: "icp4d",
  url: "{url}"
)

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:            "{version}",
  Username:           "{username}",
  Password:           "{password}",
  ICP4DURL:           "https://{icp4d_cluster_host}{:port}",
  AuthenticationType: "icp4d",
  URL:                "{url}",
})

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

let discovery = Discovery(version: "{version}", username: "{username}", password: "{password}")
discovery.serviceURL = "{url}"

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

Icp4dConfig icp4dConfig = new Icp4dConfig(
    Url: "https://{icp4d_cluster_host}{:port}",
    Username: "{username}",
    Password: "{password}",
);

Discovery discovery = new Discovery("{version}", icp4dConfig);
discovery.SetEndpoint("{url}");

SDK managing the token.

Replace {icp4d_cluster_host}, {port}, and {url} with the details for the service instance. Replace {username} and {password} with your IBM Cloud Pak for Data credentials. Replace {version} with the service version date.

Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
{
    Url = "https://{icp4d_cluster_host}{:port}",
    Username =  "{username}",
    Password =  "{password}"
};
Credentials credentials = new Credentials(tokenOptions);
while (!credentials.HasTokenData())
{
    yield return null;
}

Discovery discovery = new Discovery("{version}", tokenOptions);
discovery.SetEndpoint("{url}");

Service endpoint

The service endpoint is based on the IBM Cloud Pak for Data cluster and add-on service instance. The URL follows this pattern:

https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api
  • {icp4d_cluster_host} represents the name or IP address where your cluster is deployed.
  • {port} represents the port number that the service listens to.
  • {release} represents the release name specified when the Helm chart was installed.
  • {instance_id} represents the identifier of the service instance.

To find the base URL, view the details for the service instance from the IBM Cloud Pak for Data web client.

Use that URL in your requests to IBM Watson Discovery for IBM Cloud Pak for Data.

Set the URL by calling the setEndPoint() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the set_url() method of the service instance.

Set the correct service URL by calling the url parameter when you create the service instance or by calling the url= method of the service instance.

Set the correct service URL by the URL parameter when you create the service instance or by calling the SetURL= method of the service instance.

Set the correct service URL by setting the serviceURL property of the service instance.

Set the correct service URL by calling the SetEndpoint() method of the service instance.

Set the correct service URL by setting the Url property of the service instance.

Example

curl -H "Authorization: Bearer {token}" -X {request_method} "https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api/v1/{method}"

Example

discovery.setEndPoint("https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");

Example

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: '{username}',
  password: '{password}',
  icp4d_url: 'https://{icp4d_cluster_host}{:port}',
  authentication_type: 'icp4d',
  url: 'https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api',
});

Examples in the constructor and after instantiation

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='{username}',
    password='{password}',
    icp4d_url='https://{icp4d_cluster_host}{:port}',
    authentication_type='icp4d',
    url='https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api'
)

or

discovery.set_url('{url}')

Examples in the constructor and after instantiation

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version:             "{version}",
  username:            "{username}",
  password:            "{password}",
  icp4d_url:           "https://{icp4d_cluster_host}{:port}",
  authentication_type: "icp4d",
  url:                 "https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
)

or

discovery.url = "https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"

Examples in the constructor and after instantiation

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:            "{version}",
  Username:           "{username}",
  Password:           "{password}",
  ICP4DURL:           "https://{icp4d_cluster_host}{:port}",
  AuthenticationType: "icp4d",
  URL:                "https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api",
})

or

discovery.SetURL("https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api")

Example

let discovery = Discovery(version: "{version}", username: "{username}", password: "{password}")
discovery.serviceURL = "https://{icp4d_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"

Example

Icp4dConfig icp4dConfig= new Icp4dConfig(
    Url: "https://{icp4d_cluster_host}{:port}",
    Username: "{username}",
    Password: "{password}",
);

Discovery discovery = new Discovery("{version}", icp4dConfig);
discovery.SetEndpoint("{url}");

Default URL

https://gateway.watsonplatform.net/discovery/api

Example for the Washington DC location

Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
{
    Url = "https://{icp4d_cluster_host}{:port}",
    Username = "{username}",
    Password = "{password}"
};
Credentials credentials = new Credentials(tokenOptions);
while (!credentials.HasTokenData())
{
    yield return null;
}

DiscoveryService discovery = new DiscoveryService("{version}", credentials);
discovery.Url = "{url}";

Disabling SSL verification

All Watson services use Secure Sockets Layer (SSL) (or Transport Layer Security (TLS)) for secure connections between the client and server. The connection is verified against the local certificate store to ensure authentication, integrity, and confidentiality.

If you use a self-signed certificate, you need to disable SSL verification to make a successful connection.

Enabling SSL verification is highly recommended. Disabling SSL jeopardizes the security of the connection and data. Disable SSL only if absolutely necessary, and take steps to enable SSL as soon as possible.

To disable SSL verification for a curl request, use the --insecure (-k) option with the request.

To disable SSL verification, create an HttpConfigOptions object and set the disableSslVerification property to true. Then pass the object to the service instance by using the configureClient method.

To disable SSL verification, set the disable_ssl_verification parameter to true when you create the service instance.

To disable SSL verification, call the disable_SSL_verification method on the service instance.

To disable SSL verification, call the configure_http_client method on the service instance and set the disable_ssl parameter to true.

To disable SSL verification, call the DisableSSLVerification method on the service instance.

To disable SSL verification, call the disableSSLVerification() method on the service instance. You cannot disable SSL verification on Linux.

To disable SSL verification, set the DisableSslVerification property in the Icp4dConfig object.

To disable SSL verification, set the DisableSslVerification property in the Icp4dTokenOptions object.

Example that disables SSL verification

curl -k -X {request_method} -H "Authorization: Bearer {token}" "{url}/v1/{method}"

Example that disables SSL verification

ICP4DConfig config = new ICP4DConfig.Builder()
  .url("https://{icp4d_cluster_host}{:port}")
  .username("{username}")
  .password("{password}")
  .disableSSLVerification(true)
  .build();
Discovery discovery = new Discovery("{version}", )config);
discovery.setEndPoint("{url}");

Example that disables SSL verification

const  = require('ibm-watson/discovery/v1');

const discovery = new DiscoveryV1({
  version: '{version}',
  username: '{username}',
  password: '{password}',
  icp4d_url: 'https://{icp4d_cluster_host}{:port}',
  authentication_type: 'icp4d',
  url: '{url}',
  disable_ssl_verification: true,
});

Example that disables SSL verification

from ibm_watson import DiscoveryV1

discovery = DiscoveryV1(
    version='{version}',
    username='{username}',
    password='{password}',
    icp4d_url='https://{icp4d_cluster_host}{:port}',
    authentication_type='icp4d',
    url='{url}'
)
discovery.disable_SSL_verification()

Example that disables SSL verification

require "ibm_watson"

discovery = IBMWatson::DiscoveryV1.new(
  version:             "{version}",
  username:            "{username}",
  password:            "{password}",
  icp4d_url:           "https://{icp4d_cluster_host}{:port}",
  authentication_type: "icp4d",
  url:                 "{url}"
)
discovery.configure_http_client(disable_ssl: true)

Example that disables SSL verification

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{
  Version:            "{version}",
  Username:           "{username}",
  Password:           "{password}",
  ICP4DURL:           "https://{icp4d_cluster_host}{:port}",
  AuthenticationType: "icp4d",
  URL:                "{url}",
})
discovery.DisableSSLVerification()

Example that disables SSL verification

let discovery = Discovery(version: "{version}", apiKey: "{apikey}")
discovery.disableSSLVerification()

Example that disables SSL verification

Icp4dConfig icp4dConfig = new Icp4dConfig(
    Url: "https://{icp4d_cluster_host}{:port}",
    Username: "{username}",
    Password: "{password}",
    DisableSslVerification: true
);

Discovery discovery = new Discovery("{version}", icp4dConfig);
discovery.SetEndpoint("{url}");

Example that disables SSL verification

Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
{
    Url = "https://{icp4d_cluster_host}{:port}",
    Username =  "{username}",
    Password =  "{password}",
    DisableSslVerification =  true
};
Credentials credentials = new Credentials(tokenOptions);
while (!credentials.HasTokenData())
{
    yield return null;
}

Discovery discovery = new Discovery("{version}", tokenOptions);
discovery.SetEndpoint("{url}");

Versioning

API requests require a version parameter that takes a date in the format version=YYYY-MM-DD. When we change the API in a backwards-incompatible way, we release a new version date.

Send the version parameter with every API request. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

Specify the version to use on API requests with the version parameter when you create the service instance. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

This documentation describes the current version of IBM Watson Discovery for IBM Cloud Pak for Data, 2019-06-28. In some cases, differences in earlier versions are noted in the descriptions of parameters and response models.

Error handling

Discovery for IBM Cloud Pak for Data uses standard HTTP response codes to indicate whether a method completed successfully. HTTP response codes in the 2xx range indicate success. A response in the 4xx range is some sort of failure, and a response in the 5xx range usually indicates an internal system error that cannot be resolved by the user. Response codes are listed with the method.

ErrorResponse

Name Description
code
integer
The HTTP response code.
error
string
General description of an error.

The Java SDK generates an exception for any unsuccessful method invocation. All methods that accept an argument can also throw an IllegalArgumentException.

Exception Description
IllegalArgumentException An illegal argument was passed to the method.

When the Java SDK receives an error response from the IBM Watson Discovery for IBM Cloud Pak for Data service, it generates an exception from the com.ibm.watson.developer_cloud.service.exception package. All service exceptions contain the following fields.

Field Description
statusCode The HTTP response code that is returned.
message A message that describes the error.

When the Node SDK receives an error response from the Discovery for IBM Cloud Pak for Data service, it creates an Error object with information that describes the error that occurred. This error object is passed as the first parameter to the callback function for the method. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Python SDK generates an exception for any unsuccessful method invocation. When the Python SDK receives an error response from the Discovery for IBM Cloud Pak for Data service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

When the Ruby SDK receives an error response from the Discovery for IBM Cloud Pak for Data service, it generates an ApiException that contains the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

The Go SDK generates an error for any unsuccessful service instantiation and method invocation. You can check for the error immediately. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Swift SDK returns a WatsonError in the completionHandler any unsuccessful method invocation. This error type is an enum that conforms to LocalizedError and contains an errorDescription property that returns an error message. Some of the WatsonError cases contain associated values that reveal more information about the error.

Field Description
errorDescription A message that describes the error.

When the .NET Standard SDK receives an error response from the Discovery service, it generates a ServiceResponseException that contains the following fields.

Field Description
Message A message that describes the error.
CodeDescription The HTTP response code that is returned.

When the Unity SDK receives an error response from the Discovery service, it generates an IBMError that contains the following fields.

Field Description
Url The URL that generated the error.
StatusCode The HTTP response code returned.
ErrorMessage A message that describes the error.
Response The contents of the response from the server.
ResponseHeaders A dictionary of headers returned by the request.

Example error handling

try {
  // Invoke a method
} catch (NotFoundException e) {
  // Handle Not Found (404) exception
} catch (RequestTooLargeException e) {
  // Handle Request Too Large (413) exception
} catch (ServiceResponseException e) {
  // Base class for all exceptions caused by error responses from the service
  System.out.println("Service returned status code "
    + e.getStatusCode() + ": " + e.getMessage());
}

Example error handling

discovery.method(params)
  .catch(err => {
    console.log('error:', err);
  });

Example error handling

from ibm_watson import ApiException
try:
    # Invoke a method
except ApiException as ex:
    print "Method failed with status code " + str(ex.code) + ": " + ex.message

Example error handling

require "ibm_watson"
begin
  # Invoke a method
rescue IBMWatson::ApiException => ex
  print "Method failed with status code #{ex.code}: #{ex.error}"
end

Example error handling

import "github.com/watson-developer-cloud/go-sdk/discoveryv1"

// Instantiate a service
discovery, discoveryErr := discoveryv1.NewDiscoveryV1(&discoveryv1.DiscoveryV1Options{})

// Check for errors
if discoveryErr != nil {
  panic(discoveryErr)
}

// Call a method
response, responseErr := discovery.methodName(&methodOptions)

// Check for errors
if responseErr != nil {
  panic(responseErr)
}

Example error handling

discovery.method() {
  response, error in

  if let error = error {
    switch error {
    case let .http(statusCode, message, metadata):
      switch statusCode {
      case .some(404):
        // Handle Not Found (404) exception
        print("Not found")
      case .some(413):
        // Handle Request Too Large (413) exception
        print("Payload too large")
      default:
        if let statusCode = statusCode {
          print("Error - code: \(statusCode), \(message ?? "")")
        }
      }
    default:
      print(error.localizedDescription)
    }
    return
  }

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }

  print(result)
}

Example error handling

try
{
    // Invoke a method
}
catch(ServiceResponseException e)
{
    Console.WriteLine("Error: " + e.Message);
}
catch (Exception e)
{
    Console.WriteLine("Error: " + e.Message);
}

Example error handling

// Invoke a method
discovery.MethodName(Callback, Parameters);

// Check for errors
private void Callback(DetailedResponse<ExampleResponse> response, IBMError error)
{
    if (error == null)
    {
        Log.Debug("ExampleCallback", "Response received: {0}", response.Response);
    }
    else
    {
        Log.Debug("ExampleCallback", "Error received: {0}, {1}, {3}", error.StatusCode, error.ErrorMessage, error.Response);
    }
}

Data handling

Additional headers

Some Watson services accept special parameters in headers that are passed with the request.

You can pass request header parameters in all requests or in a single request to the service.

To pass a request header, use the --header (-H) option with a curl request.

To pass header parameters with every request, use the setDefaultHeaders method of the service object.

To pass header parameters in a single request, use the addHeader method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the headers parameter when you create the service object.

To pass header parameters in a single request, use the headers method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the set_default_headers method of the service object.

To pass header parameters in a single request, include headers as a dict in the request.

To pass header parameters with every request, specify the add_default_headers method of the service object.

To pass header parameters in a single request, specify the headers method as a chainable method in the request.

To pass header parameters with every request, specify the SetDefaultHeaders method of the service object.

To pass header parameters in a single request, specify the Headers as a map in the request.

To pass header parameters with every request, add them to the defaultHeaders property of the service object.

To pass header parameters in a single request, pass the headers parameter to the request method.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

Example header parameter in a request

curl "Authorization: Bearer {token}" -X {request_method} --header "Request-Header: {header_value}" "{url}/v1/{method}"

Example header parameter in a request

ReturnType returnValue = discovery.methodName(parameters)
  .addHeader("Custom-Header", "{header_value}")
  .execute();

Example header parameter in a request

const parameters = {
  {parameters}
};

discovery.methodName(
  parameters,
  headers: {
    'Custom-Header': '{header_value}'
  })
   .then(result => {
    console.log(response);
  })
  .catch(err => {
    console.log('error:', err);
  });

Example header parameter in a request

response = discovery.methodName(
    parameters,
    headers = {
        'Custom-Header': '{header_value}'
    })

Example header parameter in a request

response = discovery.headers(
  "Custom-Header" => "{header_value}"
).methodName(parameters)

Example header parameter in a request

response, _ := discoveryv1.methodName(
  &methodOptions{
    Headers: map[string]string{
      "Accept": "application/json",
    },
  },
)

Example header parameter in a request

let customHeader: [String: String] = ["Custom-Header": "{header_value}"]
discovery.methodName(parameters, headers: customHeader) {
  response, error in
}

Example header parameter in a request

Icp4dConfig icp4dConfig = new Icp4dConfig(
    Url: "https://{icp4d_cluster_host}{:port}",
    Username: "{username}",
    Password: "{password}",
);

Discovery discovery = new Discovery("{version}", icp4dConfig);
discovery.WithHeader("Custom-Header", "header_value");

Example header parameter in a request

Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions()
{
    Url = "https://{icp4d_cluster_host}{:port}",
    Username =  "{username}",
    Password =  "{password}"
};
Credentials credentials = new Credentials(tokenOptions);
while (!credentials.HasTokenData())
{
    yield return null;
}

Discovery discovery = new Discovery("{version}", tokenOptions);
discovery.SetEndpoint("{url}");
discovery.WithHeader("Custom-Header", "header_value");

Response details

IBM Watson Discovery for IBM Cloud Pak for Data might return information to the application in response headers.

To access all response headers that the service returns, include the --include (-i) option with a curl request. To see detailed response data for the request, including request headers, response headers, and additional debugging information, include the --verbose (-v) option with the request.

Example request to access response headers

curl "Authorization: Bearer {token}" -X {request_method} --include "{url}/v1/{method}"

To access information in the response headers, use one of the request methods that returns details with the response: executeWithDetails(), enqueueWithDetails(), or rxWithDetails(). These methods return a Response<T> object, where T is the expected response model. Use the getResult() method to access the response object for the method, and use the getHeaders() method to access information in response headers.

Example request to access response headers

Response<ReturnType> response = discovery.methodName(parameters)
  .executeWithDetails();
// Access response from methodName
ReturnType returnValue = response.getResult();
// Access information in response headers
Headers responseHeaders = response.getHeaders();

To access information in the response headers, add the return_response parameter set to true and specify the headers attribute on the response object that is returned by the method. To access information in the response object, use the following properties.

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

const parameters = {
  {parameters}
};

parameters.return_response = true;

discovery.methodName(parameters)
  .then(response => {
    console.log(response.headers);
  })
  .catch(err => {
    console.log('error:', err);
  });

The return value from all service methods is a DetailedResponse object. To access information in the result object or response headers, use the following methods.

DetailedResponse

Method Description
get_result() Returns the response for the service-specific method.
get_headers() Returns the response header information.
get_status_code() Returns the HTTP status code.

Example request to access response headers

discovery.set_detailed_response(True)
response = discovery.methodName(parameters)
# Access response from methodName
print(json.dumps(response.get_result(), indent=2))
# Access information in response headers
print(response.get_headers())
# Access HTTP response status
print(response.get_status_code())

The return value from all service methods is a DetailedResponse object. To access information in the response object, use the following properties.

DetailedResponse

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

response = discovery.methodName(parameters)
# Access response from methodName
print response.result
# Access information in response headers
print response.headers
# Access HTTP response status
print response.status

The return value from all service methods is a DetailedResponse object. To access information in the response object or response headers, use the following methods.

DetailedResponse

Method Description
GetResult() Returns the response for the service-specific method.
GetHeaders() Returns the response header information.
GetStatusCode() Returns the HTTP status code.

Example request to access response headers

import "github.com/IBM/go-sdk-core/core"
response, _ := discoveryv1.methodName(&methodOptions{})

// Access result
core.PrettyPrint(response.GetResult(), "Result ")

// Access response headers
core.PrettyPrint(response.GetHeaders(), "Headers ")

// Access status code
core.PrettyPrint(response.GetStatusCode(), "Status Code ")

All response data is available in the WatsonResponse<T> object that is returned in each method's completionHandler.

Example request to access response headers

discovery.methodName(parameters) {
  response, error in

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }
  print(result) // The data returned by the service
  print(response?.statusCode)
  print(response?.headers)
}

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Example request to access response headers

var results = discovery.MethodName(parameters);

var result = results.Result;            //  The result object
var responseHeaders = results.Headers;  //  The response headers
var responseJson = results.Response;    //  The raw response JSON
var statusCode = results.StatusCode;    //  The response status code
Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

private void Example()
{
    discovery.MethodName(Callback, Parameters);
}

private void Callback(DetailedResponse<ResponseType> response, IBMError error)
{
    var result = response.Result;                 //  The result object
    var responseHeaders = response.Headers;       //  The response headers
    var responseJson = reresponsesults.Response;  //  The raw response JSON
    var statusCode = response.StatusCode;         //  The response status code
}

Data labels

You can remove customer data if you associate the customer and the data when you send the information to a service. First, you label the data with a customer ID, and then you can delete the data by the ID.

  • Use the X-Watson-Metadata header to associate a customer ID with the data. By adding a customer ID to a request, you indicate that it contains data that belongs to that customer.

    Specify a random or generic string for the customer ID. Do not include personal data, such as an email address. Pass the string customer_id={id} as the argument of the header.

  • Use the Delete labeled data method to remove data that is associated with a customer ID.

Labeling data is used only by methods that accept customer data. For more information about IBM Watson Discovery for IBM Cloud Pak for Data and labeling data, see Information security.

For more information about how to pass headers, see Additional headers.

Synchronous and asynchronous requests

The Java SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the ServiceCall interface.

  • To call a method synchronously, use the execute method of the ServiceCall interface. You can call the execute method directly from an instance of the service.
  • To call a method asynchronously, use the enqueue method of the ServiceCall interface to receive a callback when the response arrives. The ServiceCallback interface of the method's argument provides onResponse and onFailure methods that you override to handle the callback.

The Ruby SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the Concurrent::Async module. When you use the synchronous or asynchronous methods, an IVar object is returned. You access the DetailedResponse object by calling ivar_object.value.

For more information about the Ivar object, see the IVar class docs.

  • To call a method synchronously, either call the method directly or use the .await chainable method of the Concurrent::Async module.

    Calling a method directly (without .await) returns a DetailedResponse object.

  • To call a method asynchronously, use the .async chainable method of the Concurrent::Async module.

You can call the .await and .async methods directly from an instance of the service.

Example synchronous request

ReturnType returnValue = discovery.method(parameters).execute();

Example asynchronous request

discovery.method(parameters).enqueue(new ServiceCallback<ReturnType>() {
  @Override public void onResponse(ReturnType response) {
    . . .
  }
  @Override public void onFailure(Exception e) {
    . . .
  }
});

Example synchronous request

response = discovery.method_name(parameters)

or

response = discovery.await.method_name(parameters)

Example asynchronous request

response = discovery.async.method_name(parameters)

Methods

Add a document

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

Add a document to a collection with optional metadata.

  • The version query parameter is still required.

  • Returns immediately after the system has accepted the document for processing.

  • 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.

POST /v1/environments/{environment_id}/collections/{collection_id}/documents
(discovery *DiscoveryV1) AddDocument(addDocumentOptions *AddDocumentOptions) (*core.DetailedResponse, error)
ServiceCall<DocumentAccepted> addDocument(AddDocumentOptions addDocumentOptions)
addDocument(params, [ callback() ])
add_document(self, environment_id, collection_id, file=None, filename=None, file_content_type=None, metadata=None, **kwargs)
add_document(environment_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
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)
AddDocument(string environmentId, string collectionId, System.IO.FileStream file = null, string fileContentType = null, string metadata = null)
AddDocument(Callback<DocumentAccepted> callback, string environmentId, string collectionId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null)
Request

Instantiate the AddDocumentOptions struct and set the fields to provide parameter values for the AddDocument method.

Use the AddDocumentOptions.Builder to create a AddDocumentOptions object that contains the parameter values for the addDocument method.

Path Parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

Form Parameters

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

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

The AddDocument options.

The addDocument options.

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

Response

Information about the document that was uploaded to the collection.

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Status Code

  • The document has been accepted and will be processed.

  • Bad request if the request is incorrectly formatted. The error message contains details about what caused the request to be rejected.

  • Forbidden. Returned if you attempt to add a document to a collection in a read-only environment.

Example responses

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.

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.

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.

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.

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.

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.

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.

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.

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.

POST /v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}
(discovery *DiscoveryV1) UpdateDocument(updateDocumentOptions *UpdateDocumentOptions) (*core.DetailedResponse, error)
ServiceCall<DocumentAccepted> updateDocument(UpdateDocumentOptions updateDocumentOptions)
updateDocument(params, [ callback() ])
update_document(self, environment_id, collection_id, document_id, file=None, filename=None, file_content_type=None, metadata=None, **kwargs)
update_document(environment_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
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)
UpdateDocument(string environmentId, string collectionId, string documentId, System.IO.FileStream file = null, string fileContentType = null, string metadata = null)
UpdateDocument(Callback<DocumentAccepted> callback, string environmentId, string collectionId, string documentId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null)
Request

Instantiate the UpdateDocumentOptions struct and set the fields to provide parameter values for the UpdateDocument method.

Use the UpdateDocumentOptions.Builder to create a UpdateDocumentOptions object that contains the parameter values for the updateDocument method.

Path Parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

Form Parameters

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

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

The UpdateDocument options.

The updateDocument options.

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • 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 confiruration is 1 megabyte. Files larger than the supported size are rejected.

  • The filename for file.

  • The content type of file.

    Allowable values: [application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,text/html,application/xhtml+xml]

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

Response

Information about the document that was uploaded to the collection.

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Information about the document that was uploaded to the collection.

Example:

Status Code

  • The document has been accepted and it will be processed.

  • Bad request if the request is incorrectly formatted. The error message contains details about what caused the request to be rejected.

  • Forbidden. Returned if you attempt to add or update a document in a collection in a read-only environment.

Example responses

Delete a document

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

Deletes a document from the specified collection. Only documents that were added by using the Add a document method, Update a document method, or uploaded indiviually using the tooling can be deleted using this method. Documents added using a source crawl cannot be deleted using this method. 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'.

DELETE /v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}
(discovery *DiscoveryV1) DeleteDocument(deleteDocumentOptions *DeleteDocumentOptions) (*core.DetailedResponse, error)
ServiceCall<DeleteDocumentResponse> deleteDocument(DeleteDocumentOptions deleteDocumentOptions)
deleteDocument(params, [ callback() ])
delete_document(self, environment_id, collection_id, document_id, **kwargs)
delete_document(environment_id:, collection_id:, document_id:)
func deleteDocument(
    environmentID: String,
    collectionID: String,
    documentID: String,
    headers: [String: String]? = nil,
    completionHandler: @escaping (WatsonResponse<DeleteDocumentResponse>?, WatsonError?) -> Void)
DeleteDocument(string environmentId, string collectionId, string documentId)
DeleteDocument(Callback<DeleteDocumentResponse> callback, string environmentId, string collectionId, string documentId)
Request

Instantiate the DeleteDocumentOptions struct and set the fields to provide parameter values for the DeleteDocument method.

Use the DeleteDocumentOptions.Builder to create a DeleteDocumentOptions object that contains the parameter values for the deleteDocument method.

Path Parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

The DeleteDocument options.

The deleteDocument options.

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

  • The ID of the document.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

Response

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Information about the deleted document.

Status Code

  • The document was successfully deleted.

  • Bad request.

    A bad request is returned any time there is a problem with the request itself.

  • Forbidden. Returned if you attempt to delete a document in a collection in a read-only environment.

No Sample Response

This method does not specify any sample responses.

Query a collection (GET)

After your content is uploaded and enriched by Discovery, you can build queries to search your content. For details, see the Query documentation.

GET /v1/environments/{environment_id}/collections/{collection_id}/query
Request

Path Parameters

  • The ID of the environment. The value of this parameter must always be default.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

  • The ID of the collection.

    Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

Query Parameters

  • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

  • 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.

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

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

  • 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.

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

    Default: 10

  • A comma-separated list of the portion of the document hierarchy to return.

  • 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

  • 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.

  • 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.

    Default: false

  • When true and the natural_language_query parameter is used, the natural_language_query parameter is spell checked. The most likely correction is returned in the suggested_query field of the response (if one exists).

    Default: false

    Response

    A response containing the documents and aggregations for the query.

    Status Code

    • Query executed successfully.

    • Bad request.

    • query and natural_language_query can be used in the same request only if training is complete.

    • Query timed out.

    Example responses

    Query a collection

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

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

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

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

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

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

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

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

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

    POST /v1/environments/{environment_id}/collections/{collection_id}/query
    (discovery *DiscoveryV1) Query(queryOptions *QueryOptions) (*core.DetailedResponse, error)
    ServiceCall<QueryResponse> query(QueryOptions queryOptions)
    query(params, [ callback() ])
    query(self, environment_id, collection_id, filter=None, query=None, natural_language_query=None, aggregation=None, count=None, return_fields=None, offset=None, sort=None, highlight=None, spelling_suggestions=None, **kwargs)
    query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, spelling_suggestions: nil)
    func query(
        environmentID: String,
        collectionID: String,
        filter: String? = nil,
        query: String? = nil,
        naturalLanguageQuery: String? = nil,
        aggregation: String? = nil,
        count: Int? = nil,
        returnFields: String? = nil,
        offset: Int? = nil,
        sort: String? = nil,
        highlight: Bool? = nil,
        headers: [String: String]? = nil,
        completionHandler: @escaping (WatsonResponse<QueryResponse>?, WatsonError?) -> Void)
    Query(string environmentId, string collectionId, QueryLarge queryLong = null)
    Query(Callback<QueryResponse> callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, string returnFields = null, long? offset = null, string sort = null, bool? highlight = null, bool? spellingSuggestions = null)
    Request

    Instantiate the QueryOptions struct and set the fields to provide parameter values for the Query method.

    Use the QueryOptions.Builder to create a QueryOptions object that contains the parameter values for the query method.

    Path Parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

    Query Parameters

    • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

    An object that represents the query to be submitted.

    The Query options.

    The query options.

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • 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.

    • 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.

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

    • 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.

    • Number of results to return.

    • A comma-separated list of the portion of the document hierarchy to return.

    • 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.

    • 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.

    • 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.

      Default: false

    • When true and the natural_language_query parameter is used, the natural_languge_query parameter is spell checked. The most likely correction is retunred in the suggested_query field of the response (if one exists).

      Default: false

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • 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.

    • 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.

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

    • 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.

    • Number of results to return.

    • A comma-separated list of the portion of the document hierarchy to return.

    • 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.

    • 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.

    • 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.

      Default: false

    • When true and the natural_language_query parameter is used, the natural_languge_query parameter is spell checked. The most likely correction is retunred in the suggested_query field of the response (if one exists).

      Default: false

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • 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.

    • 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.

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

    • 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.

    • Number of results to return.

    • A comma-separated list of the portion of the document hierarchy to return.

    • 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.

    • 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.

    • 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.

      Default: false

    • When true and the natural_language_query parameter is used, the natural_languge_query parameter is spell checked. The most likely correction is retunred in the suggested_query field of the response (if one exists).

      Default: false

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • 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.

    • 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.

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

    • 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.

    • Number of results to return.

    • A comma-separated list of the portion of the document hierarchy to return.

    • 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.

    • 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.

    • 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.

      Default: false

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • An object that represents the query to be submitted.

    parameters

    • The ID of the environment. The value of this parameter must always be default.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • The ID of the collection.

      Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

    • 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.

    • 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.

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

    • 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.

    • Number of results to return.

    • A comma-separated list of the portion of the document hierarchy to return.

    • 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.

    • 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.

    • 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.

      Default: false

    • When true and the natural_language_query parameter is used, the natural_languge_query parameter is spell checked. The most likely correction is retunred in the suggested_query field of the response (if one exists).

      Default: false

        Response

        A response containing the documents and aggregations for the query.

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        A response containing the documents and aggregations for the query.

        Example:

        Status Code

        • Query executed successfully.

        • Bad request.

        • query and natural_language_query can be used in the same request only if training is complete.

        • Query timed out.

        Example responses

        Get Autocomplete Suggestions

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        Returns completion query suggestions for the specified prefix.

        GET /v1/environments/{environment_id}/collections/{collection_id}/autocompletion
        (discovery *DiscoveryV1) GetAutocompletion(getAutocompletionOptions *GetAutocompletionOptions) (*core.DetailedResponse, error)
        ServiceCall<Completions> getAutocompletion(GetAutocompletionOptions getAutocompletionOptions)
        getAutocompletion(params, [ callback() ])
        get_autocompletion(self, environment_id, collection_id, field=None, prefix=None, count=None, **kwargs)
        get_autocompletion(environment_id:, collection_id:, field: nil, prefix: nil, count: nil)
        GetAutocompletion(string environmentId, string collectionId, string field = null, string prefix = null, long? count = null)
        GetAutocompletion(Callback<Completions> callback, string environmentId, string collectionId, string field = null, string prefix = null, long? count = null)
        Request

        Instantiate the GetAutocompletionOptions struct and set the fields to provide parameter values for the GetAutocompletion method.

        Use the GetAutocompletionOptions.Builder to create a GetAutocompletionOptions object that contains the parameter values for the getAutocompletion method.

        Path Parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

        Query Parameters

        • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are

        • The number of autocompletion suggestions to return.

          Default: 5

        The GetAutocompletion options.

        The getAutocompletion options.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are.

        • The number of autocompletion suggestions to return.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are.

        • The number of autocompletion suggestions to return.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are.

        • The number of autocompletion suggestions to return.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are.

        • The number of autocompletion suggestions to return.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

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

        • The prefix to use for autocompletion. For example, the prefix Ho could autocomplete to Hot, Housing, or How do I upgrade. Possible completions are.

        • The number of autocompletion suggestions to return.

        Response

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        An object containing an array of autocompletion suggestions.

        Status Code

        • Object containing array of possible completions.

        • The specified field does not exist.

        No Sample Response

        This method does not specify any sample responses.

        List training data

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        Lists the training data for the specified collection.

        GET /v1/environments/{environment_id}/collections/{collection_id}/training_data
        (discovery *DiscoveryV1) ListTrainingData(listTrainingDataOptions *ListTrainingDataOptions) (*core.DetailedResponse, error)
        ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions)
        listTrainingData(params, [ callback() ])
        list_training_data(self, environment_id, collection_id, **kwargs)
        list_training_data(environment_id:, collection_id:)
        func listTrainingData(
            environmentID: String,
            collectionID: String,
            headers: [String: String]? = nil,
            completionHandler: @escaping (WatsonResponse<TrainingDataSet>?, WatsonError?) -> Void)
        ListTrainingData(string environmentId, string collectionId)
        ListTrainingData(Callback<TrainingDataSet> callback, string environmentId, string collectionId)
        Request

        Instantiate the ListTrainingDataOptions struct and set the fields to provide parameter values for the ListTrainingData method.

        Use the ListTrainingDataOptions.Builder to create a ListTrainingDataOptions object that contains the parameter values for the listTrainingData method.

        Path Parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression ^[a-zA-Z0-9_-]*$

        Query Parameters

        • A date (YYYY-MM-DD) that identifies the specific version of the API to use when processing the request.

        The ListTrainingData options.

        The listTrainingData options.

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        parameters

        • The ID of the environment. The value of this parameter must always be default.

          Constraints: 1 ≤ length ≤ 255, Value must match regular expression /^[a-zA-Z0-9_-]*$/

        • The ID of the collection.

          Constraints: 1 ≤