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.
This documentation describes Java SDK major version 8. For details about how to migrate your code from the previous version see the migration guide.
This documentation describes Node SDK major version 5. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes Python SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes Ruby SDK major version 1. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes .NET Standard SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes Go SDK major version 1. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes Swift SDK major version 3. For details about how to migrate your code from the previous version, see the migration guide.
This documentation describes Unity SDK major version 4. For details about how to migrate your code from the previous version, see the migration guide.
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.
- Set the project settings for both the Scripting Runtime Version and the Api Compatibility Level to
- 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>8.1.0</version>
</dependency>
Gradle
compile 'com.ibm.watson:ibm-watson:8.1.0'
GitHub
The code examples on this tab use the client library that is provided for Node.js.
Installation
npm install ibm-watson@^5.2.0
GitHub
The code examples on this tab use the client library that is provided for Python.
Installation
pip install --upgrade "ibm-watson>=4.1.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@v1.2.0
GitHub
The code examples on this tab use the client library that is provided for Swift.
Cocoapods
pod 'IBMWatsonDiscoveryV1', '~> 3.1.0'
Carthage
github "watson-developer-cloud/swift-sdk" ~> 3.1.0
Swift Package Manager
.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "3.1.0")
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 4.1.0
.NET CLI
dotnet add package IBM.Watson.Discovery.v1 -version 4.1.0
PackageReference
<PackageReference Include="IBM.Watson.Discovery.v1" Version="4.1.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 a bearer token in an Authorization
header. The token is associated with a username.
For testing and development, you can use the bearer token that's displayed in the IBM Cloud Pak for Data web client. To find this token, view the details for the provisioned service instance. The details also include the service endpoint URL. Don't use this token in production because it does not expire.
For production use, create a user in the IBM Cloud Pak for Data web client to use for authentication. Generate a token from that user's credentials with the POST preauth/validateAuth method.
To authenticate to the API, pass either username and password credentials or a bearer token that you generate. Username and password credentials use basic authentication. However, the SDK manages the lifecycle of the token. Tokens are temporary security credentials. If you pass a token, you maintain the token lifecycle.
For production use, create a user in the IBM Cloud Pak for Data web client to use for authentication, and decide which authentication mechanism to use.
- To have the SDK manage the lifecycle of the token, use the username and password for that new user in your calls.
- To manage the lifecycle of the token yourself, generate a token from that user's credentials. Call the POST preauth/validateAuth method to generate the token, and then pass the token in an
Authorization
header in your calls. You can see an example of the method on the Curl tab.
Don't use the bearer token that's displayed in the web client for the instance except during testing and development because that token does not expire.
To find your value for {cpd_cluster_host}
, {:port}
, and {instance_id}
, view the service credentials by viewing the details for the provisioned service instance in the IBM Cloud Pak for Data web client.
Generating a bearer token. The response includes an accessToken
property.
Replace {cpd_cluster_host}
and {port}
with the details for the service instance. Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials.
curl -k -u "{username}:{password}" "https://{cpd_cluster_host}{:port}/v1/preauth/validateAuth"
Authenticating to the API. Replace {token}
with your details.
curl -H "Authorization: Bearer {token}" "https://{cpd_cluster_host}{:port}/v1/{method}"
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Discovery discovery = new Discovery("{version}", authenticator);
discovery.setServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
const DiscoveryV1 = require('ibm-watson/discovery/v1');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
const discovery = new DiscoveryV1({
version: '{version}',
authenticator: new CloudPakForDataAuthenticator({
username: '{username}',
password: '{password}',
url: 'https://{cpd_cluster_host}{:port}',
}),
url: 'https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api',
});
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
from ibm_watson import DiscoveryV1
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
authenticator = CloudPakForDataAuthenticator(
'{username}',
'{password}',
'https://{cpd_cluster_host}{:port}'
)
discovery = DiscoveryV1(
version='{version}',
authenticator=authenticator
)
discovery.set_service_url('https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api')
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
require "ibm_watson/authenticators"
require "ibm_watson/discovery_v1"
include IBMWatson
authenticator = Authenticators::CloudPakForDataAuthenticator.new(
username: "{username}",
password: "{password}",
url: "https://{cpd_cluster_host}{:port}"
)
discovery = DiscoveryV1.new(
version: "{version}",
authenticator: authenticator
)
discovery.service_url = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
import (
"github.com/IBM/go-sdk-core/core"
"github.com/watson-developer-cloud/go-sdk/discoveryv1"
)
func main() {
authenticator := &core.CloudPakForDataAuthenticator{
URL: "https://{cpd_cluster_host}{:port}",
Username: "{username}",
Password: "{password}",
}
options := &discoveryv1.DiscoveryV1Options{
Version: "{version}",
Authenticator: authenticator,
}
discovery, discoveryErr := discoveryv1.NewDiscoveryV1(options)
if discoveryErr != nil {
panic(discoveryErr)
}
discovery.SetServiceURL("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api")
}
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let discovery = Discovery(version: "{version}", authenticator: authenticator)
discovery.serviceURL = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
DiscoveryService discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
SDK managing the token.
Replace {username}
and {password}
with your IBM Cloud Pak for Data credentials. Replace {version}
with the service version date. For {cpd_cluster_host}
, {port}
, {release}
, and {instance_id}
, see Service endpoint.
var authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
while (!authenticator.CanAuthenticate())
yield return null;
var discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
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://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api
{cpd_cluster_host}
represents the name or IP address of your deployed cluster.{port}
represents the port number on which the service listens.{release}
represents the release name that was 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 setServiceUrl()
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://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api/v1/{method}"
Example
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Discovery discovery = new Discovery("{version}", authenticator);
discovery.setServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
Example
const DiscoveryV1 = require('ibm-watson/discovery/v1');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
const discovery = new DiscoveryV1({
version: '{version}',
authenticator: new CloudPakForDataAuthenticator({
username: '{username}',
password: '{password}',
url: 'https://{cpd_cluster_host}{:port}',
}),
url: 'https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api',
});
Example
from ibm_watson import DiscoveryV1
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
authenticator = CloudPakForDataAuthenticator(
'{username}',
'{password}',
'https://{cpd_cluster_host}{:port}'
)
discovery = DiscoveryV1(
version='{version}',
authenticator=authenticator
)
discovery.set_service_url('https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api')
Example
require "ibm_watson/authenticators"
require "ibm_watson/discovery_v1"
include IBMWatson
authenticator = Authenticators::CLoudPakForDataAuthenticator.new(
username: "{username}",
password: "{password}",
url: "https://{cpd_cluster_host}{:port}"
)
discovery = DiscoveryV1.new(
version: "{version}",
authenticator: authenticator
)
discovery.service_url = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
Example
discovery, discoveryErr := discoveryv1.NewDiscoveryV1(options)
if discoveryErr != nil {
panic(discoveryErr)
}
discovery.SetServiceURL("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api")
Example
let authenticator = CloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let discovery = Discovery(version: "{version}", authenticator: authenticator)
discovery.serviceURL = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
Example
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
DiscoveryService discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
Default URL
https://gateway.watsonplatform.net/discovery/api
Example for the Washington DC location
var authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
while (!authenticator.CanAuthenticate())
yield return null;
var discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
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 disableSslVerification
parameter to true
when you create the service instance.
To disable SSL verification, update the call in two places. Specify True
on disable_ssl_verification
in the authenticator and on the set_disable_ssl_verification
method for the service instance.
To disable SSL verification, specify true
on the configure_http_client
method for the service instance.
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 to true
in the Icp4dConfig
object and set the DisableSslVerification
method to true
on the service instance.
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
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Discovery discovery = new Discovery("{version}", authenticator);
discovery.setServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api";
HttpConfigOptions configOptions = new HttpConfigOptions.Builder()
.disableSslVerification(true)
.build();
discovery.configureClient(configOptions);
Example that disables SSL verification
const DiscoveryV1 = require('ibm-watson/discovery/v1');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
const discovery = new DiscoveryV1({
version: '{version}',
authenticator: new CloudPakForDataAuthenticator({
username: '{username}',
password: '{password}',
url: 'https://{cpd_cluster_host}{:port}',
}),
url: 'https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api',
disableSslVerification: true,
});
Example that disables SSL verification
from ibm_watson import DiscoveryV1
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
authenticator = CloudPakForDataAuthenticator(
'{username}',
'{password}',
'https://{cpd_cluster_host}{:port}',
disable_ssl_verification=True
)
discovery = DiscoveryV1(
version='{version}',
authenticator=authenticator
)
discovery.set_service_url('https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api')
discovery.set_disable_ssl_verification(True)
Example that disables SSL verification
require "ibm_watson/authenticators"
require "ibm_watson/discovery_v1"
include IBMWatson
authenticator = Authenticators::CLoudPakForDataAuthenticator.new(
username: "{username}",
password: "{password}",
url: "https://{cpd_cluster_host}{:port}"
)
discovery = DiscoveryV1.new(
version: "{version}",
authenticator: authenticator
)
discovery.service_url = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
discovery.configure_http_client(disable_ssl: true)
Example that disables SSL verification
discovery, discoveryErr := discoveryv1.NewDiscoveryV1(options)
if discoveryErr != nil {
panic(discoveryErr)
}
discovery.SetServiceURL("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api")
discovery.DisableSSLVerification()
Example that disables SSL verification
let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let discovery = Discovery(version: "{version}", authenticator: authenticator)
discovery.serviceURL = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"
discovery.disableSSLVerification()
Example that disables SSL verification
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
DiscoveryService discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
discovery.DisableSslVerification(true);
Example that disables SSL verification
var authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
while (!authenticator.CanAuthenticate())
yield return null;
var discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
discovery.DisableSslVerification = true;
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-11-22
. 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(options)
// Check for errors
if discoveryErr != nil {
panic(discoveryErr)
}
// Call a method
result, 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);
}
}
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
result, response, responseErr := discovery.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
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
DiscoveryService discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
discovery.WithHeader("Custom-Header", "header_value");
Example header parameter in a request
var authenticator = new CloudPakForDataAuthenticator(
url: "https://{cpd_cluster_host}{:port}",
username: "{username}",
password: "{password}"
);
while (!authenticator.CanAuthenticate())
yield return null;
var discovery = new DiscoveryService("{version}", authenticator);
discovery.SetServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api");
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();
All response data is available in the Response<T>
object that is returned by each 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
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"
"github.com/watson-developer-cloud/go-sdk/discoveryv1"
)
result, response, responseErr := discovery.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 theServiceCall
interface. You can call theexecute
method directly from an instance of the service. - To call a method asynchronously, use the
enqueue
method of theServiceCall
interface to receive a callback when the response arrives. The ServiceCallback interface of the method's argument providesonResponse
andonFailure
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 theConcurrent::Async
module.Calling a method directly (without
.await
) returns aDetailedResponse
object.- To call a method asynchronously, use the
.async
chainable method of theConcurrent::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)
Related information
- Discovery for IBM Cloud Pak for Data docs
- Release notes
- Javadoc for Discovery
- Javadoc for sdk-core
Methods
List collections
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
Lists existing collections for the specified project.
GET /v2/projects/{project_id}/collections
(discovery *DiscoveryV2) ListCollections(listCollectionsOptions *ListCollectionsOptions) (result *ListCollectionsResponse, response *core.DetailedResponse, err error)
ServiceCall<ListCollectionsResponse> listCollections(ListCollectionsOptions listCollectionsOptions)
listCollections(params, [callback()])
list_collections(self, project_id, **kwargs)
list_collections(project_id:)
func listCollections(
projectID: String,
headers: [String: String]? = nil,
completionHandler: @escaping (WatsonResponse<ListCollectionsResponse>?, WatsonError?) -> Void)
ListCollections(string projectId)
ListCollections(Callback<ListCollectionsResponse> callback, string projectId)
Instantiate the ListCollectionsOptions
struct and set the fields to provide parameter values for the ListCollections
method.
Use the ListCollectionsOptions.Builder
to create a ListCollectionsOptions
object that contains the parameter values for the listCollections
method.
Path Parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
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 ListCollections options.
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
The listCollections options.
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
curl -H "Authorization: Bearer {token}" 'https://{cpd_cluster_host}:{port}/discovery/{release}/instance/{instance_id}/api/v2/projects/{project_id}/collections?version=2019-11-29'
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}"); Discovery discovery = new Discovery("2019-11-22", authenticator); discovery.setServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"); ListCollectionsOptions options = new ListCollectionsOptions.Builder() .projectId("{project_id}") .build(); ListCollectionsResponse response = discovery.listCollections(options).execute().getResult(); System.out.println(response);
const DiscoveryV2 = require('ibm-watson/discovery/v2'); const { CloudPakForDataAuthenticator } = require('ibm-watson/auth'); const discovery = new DiscoveryV2({ authenticator: new CloudPakForDataAuthenticator({ url: 'https://{cpd_cluster_host}{:port}', username: '{username}', password: '{password}', }), version: '2019-11-22', url: 'https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api', }); const params = { projectId: '{projectId}', }; discovery.listCollections(params) .then(response => { console.log(JSON.stringify(response.result, null, 2)); }) .catch(err => { console.log('error:', err); });
import json from ibm_watson import DiscoveryV2 from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator authenticator = CloudPakForDataAuthenticator( '{username}', '{password}', 'https://{cpd_cluster_host}{:port}', disable_ssl_verification=True) discovery = DiscoveryV2( version='2019-11-22', authenticator=authenticator ) discovery.set_service_url('{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}') response = discovery.list_collections( project_id='{project_id}' ).get_result() print(json.dumps(response, indent=2))
require "json" require "ibm_watson/authenticators" require "ibm_watson/discovery_v2" include IBMWatson authenticator = Authenticators::CloudPakForDataAuthenticator.new( username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}" ) discovery = DiscoveryV2.new( version: "2019-11-22", authenticator: authenticator ) discovery.service_url = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api" service_response = discovery.list_collections( project_id: "{project_id}" ) puts JSON.pretty_generate(service_response.result)
package main import ( "encoding/json" "fmt" "github.com/IBM/go-sdk-core/core" "github.com/watson-developer-cloud/go-sdk/discoveryv2" ) func main() { authenticator := &core.CloudPakForDataAuthenticator{ URL: "https://{cpd_cluster_host}{:port}", Username: "{username}", Password: "{password}", DisableSSLVerification: true, } options := &discoveryv2.DiscoveryV2Options{ Version: "2019-11-22", Authenticator: authenticator, } service, serviceErr := discoveryv2.NewDiscoveryV2(options) if serviceErr != nil { panic(serviceErr) } service.SetServiceURL("{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}") result, _, responseErr := service.ListCollections(&discoveryv2.ListCollectionsOptions{ ProjectID: core.StringPtr("{project_id}"), }) if responseErr != nil { panic(responseErr) } b, _ := json.MarshalIndent(result, "", " ") fmt.Println(string(b)) }
let authenticator = WatsonCloudPakForDataAuthenticator(username: username, password: password, url: url) let discovery = Discovery(version: "2019-11-29", authenticator: authenticator) discovery.serviceURL = "{url}" discovery.listCollections(projectID: "{project_id}") { response, error in guard let collections = response?.result else { print(error?.localizedDescription ?? "unexpected error") return } print(collections) }
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator( url: "https://{cpd_cluster_host}{:port}", username: "{username}", password: "{password}" ); DiscoveryService service = new DiscoveryService("2019-11-22", authenticator); service.SetServiceUrl("{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}"); var result = service.ListCollections( projectId: "{project_id}" ); Console.WriteLine(result.Response);
var authenticator = new CloudPakForDataAuthenticator( url: "https://{cpd_cluster_host}{:port}", username: "{username}", password: "{password}" ); while (!authenticator.CanAuthenticate()) yield return null; var discovery = new DiscoveryService("2019-11-22", authenticator); discovery.SetServiceUrl("{url}"); ListCollectionsResponse listCollectionsResponse = null; service.ListCollections( callback: (DetailedResponse<ListCollectionsResponse> response, IBMError error) => { Log.Debug("DiscoveryServiceV2", "ListCollections result: {0}", response.Response); listCollectionsResponse = response.Result; }, projectId: "{project_id}" ); while (listCollectionsResponse == null) yield return null;
Response object containing an array of collection details.
An array containing information about each collection in the project.
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
Collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
Collections
Response object containing an array of collection details.
An array containing information about each collection in the project.
Example:The unique identifier of the collection.
The name of the collection.
Constraints: 0 ≤ length ≤ 255
Collections
Status Code
Successful response.
Bad request.
{ "collections": [ { "collection_id": "f1360220-ea2d-4271-9d62-89a910b13c37", "name": "example" } ] }
{ "collections": [ { "collection_id": "f1360220-ea2d-4271-9d62-89a910b13c37", "name": "example" } ] }
Query a project
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
By using this method, you can construct queries. For details, see the Discovery documentation.
POST /v2/projects/{project_id}/query
(discovery *DiscoveryV2) Query(queryOptions *QueryOptions) (result *QueryResponse, response *core.DetailedResponse, err error)
ServiceCall<QueryResponse> query(QueryOptions queryOptions)
query(params, [callback()])
query(self, project_id, collection_ids=None, filter=None, query=None, natural_language_query=None, aggregation=None, count=None, return_=None, offset=None, sort=None, highlight=None, spelling_suggestions=None, table_results=None, suggested_refinements=None, passages=None, **kwargs)
query(project_id:, collection_ids: nil, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, _return: nil, offset: nil, sort: nil, highlight: nil, spelling_suggestions: nil, table_results: nil, suggested_refinements: nil, passages: nil)
func query(
projectID: String,
collectionIDs: [String]? = nil,
filter: String? = nil,
query: String? = nil,
naturalLanguageQuery: String? = nil,
aggregation: String? = nil,
count: Int? = nil,
`return`: [String]? = nil,
offset: Int? = nil,
sort: String? = nil,
highlight: Bool? = nil,
spellingSuggestions: Bool? = nil,
tableResults: QueryLargeTableResults? = nil,
suggestedRefinements: QueryLargeSuggestedRefinements? = nil,
passages: QueryLargePassages? = nil,
headers: [String: String]? = nil,
completionHandler: @escaping (WatsonResponse<QueryResponse>?, WatsonError?) -> Void)
Query(string projectId, List<string> collectionIds = null, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List<string> _return = null, long? offset = null, string sort = null, bool? highlight = null, bool? spellingSuggestions = null, QueryLargeTableResults tableResults = null, QueryLargeSuggestedRefinements suggestedRefinements = null, QueryLargePassages passages = null)
Query(Callback<QueryResponse> callback, string projectId, List<string> collectionIds = null, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List<string> _return = null, long? offset = null, string sort = null, bool? highlight = null, bool? spellingSuggestions = null, QueryLargeTableResults tableResults = null, QueryLargeSuggestedRefinements suggestedRefinements = null, QueryLargePassages passages = null)
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 project. This information can be found from the deploy page of the Discovery administrative tooling.
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.
A comma-separated list of collection IDs to be queried against.
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.
Default:
10
A list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
table_results
Configuration for suggested refinements
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
Default:
10
suggested_refinements
Configuration for passage retrieval
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
Default:
5
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
Default:
10
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
Default:
400
passages
The Query options.
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
TableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
SuggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
Passages
The query options.
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
tableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
tableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
table_results
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggested_refinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
table_results
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggested_refinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
tableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
tableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
parameters
The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling.
Constraints: 1 ≤ length ≤ 255, Value must match regular expression
/^[a-zA-Z0-9_-]*$/
A comma-separated list of collection IDs to be queried against.
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 list of the fields in the document hierarchy to return. If this parameter not specified, then all top-level fields are returned.
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_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
Configuration for table retrieval.
Whether to enable table retrieval.
Default:
false
Maximum number of tables to return.
tableResults
Configuration for suggested refinements.
Whether to perform suggested refinements.
Default:
false
Maximum number of suggested refinements texts to be returned. The default is
10
. The maximum is100
.Constraints: 1 ≤ value ≤ 100
suggestedRefinements
Configuration for passage retrieval.
A passages query that returns the most relevant passages from the results.
Default:
false
When
true
, passages will be returned whithin their respective result.Default:
true
Maximum number of passages to return per result.
A list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included.
The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is
10
. The maximum is100
.Constraints: value ≤ 100
The approximate number of characters that any one passage will have.
Constraints: 50 ≤ value ≤ 2000
passages
curl -X POST -H "Authorization: Bearer {token}" -d '{"collection_ids": ["{collection_id_1}","{collection_id_1},"]"query": "text:IBM"}' 'https://{cpd_cluster_host}:{port}/discovery/{release}/instance/{instance_id}/api/v2/projects/{project_id}/query?version=2019-11-29'
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}"); Discovery discovery = new Discovery("2019-11-22", authenticator); discovery.setServiceUrl("https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api"); QueryOptions options = new QueryOptions.Builder() .projectId("{project_id}") .query("{field}:{value}") .build(); QueryResponse response = discovery.query(options).execute().getResult(); System.out.println(response);
const DiscoveryV2 = require('ibm-watson/discovery/v2'); const { CloudPakForDataAuthenticator } = require('ibm-watson/auth'); const discovery = new DiscoveryV2({ authenticator: new CloudPakForDataAuthenticator({ url: 'https://{cpd_cluster_host}{:port}', username: '{username}', password: '{password}', }), version: '2019-11-22', url: 'https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api', }); const params = { projectId: '{projectId}', query: '{field}:{value}', }; discovery.query(params) .then(response => { console.log(JSON.stringify(response.result, null, 2)); }) .catch(err => { console.log('error:', err); });
import json from ibm_watson import DiscoveryV2 from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator authenticator = CloudPakForDataAuthenticator( '{username}', '{password}', 'https://{cpd_cluster_host}{:port}', disable_ssl_verification=True) discovery = DiscoveryV2( version='2019-11-22', authenticator=authenticator ) discovery.set_service_url('{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}') response = discovery.query( project_id='{project_id}', query='{field:value}' ).get_result() print(json.dumps(response, indent=2))
require "json" require "ibm_watson/authenticators" require "ibm_watson/discovery_v2" include IBMWatson authenticator = Authenticators::CloudPakForDataAuthenticator.new( username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}" ) discovery = DiscoveryV2.new( version: "2019-11-22", authenticator: authenticator ) discovery.service_url = "https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api" service_response = discovery.query( project_id: "{project_id}", qhery: "{field}:{value}" ) puts JSON.pretty_generate(service_response.result)
package main import ( "encoding/json" "fmt" "github.com/IBM/go-sdk-core/core" "github.com/watson-developer-cloud/go-sdk/discoveryv2" ) func main() { authenticator := &core.CloudPakForDataAuthenticator{ URL: "https://{cpd_cluster_host}{:port}", Username: "{username}", Password: "{password}", DisableSSLVerification: true, } options := &discoveryv2.DiscoveryV2Options{ Version: "2019-11-22", Authenticator: authenticator, } service, serviceErr := discoveryv2.NewDiscoveryV2(options) if serviceErr != nil { panic(serviceErr) } service.SetServiceURL("{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}") result, _, responseErr := service.Query(&discoveryv2.QueryOptions{ ProjectID: core.StringPtr("{project_id}"), Query: core.StringPtr("{field}:{value}"), }) if responseErr != nil { panic(responseErr) } b, _ := json.MarshalIndent(result, "", " ") fmt.Println(string(b)) }
let authenticator = WatsonCloudPakForDataAuthenticator(username: username, password: password, url: url) let discovery = Discovery(version: "2019-11-29", authenticator: authenticator) discovery.serviceURL = "{url}" discovery.query(projectID: "{project_id}") { response, error in guard let results = response?.result else { print(error?.localizedDescription ?? "unexpected error") return } print(results) }
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator( url: "https://{cpd_cluster_host}{:port}", username: "{username}", password: "{password}" ); DiscoveryService service = new DiscoveryService("2019-11-22", authenticator); service.SetServiceUrl("{https://{cpd_cluster_host}{:port}/discovery/{release}/instances/{instance_id}/api}"); var result = service.Query( projectId: "{project_id}", query: "{field}:{value}" ); Console.WriteLine(result.Response);
var authenticator = new CloudPakForDataAuthenticator( url: "https://{cpd_cluster_host}{:port}", username: "{username}", password: "{password}" ); while (!authenticator.CanAuthenticate()) yield return null; var discovery = new DiscoveryService("2019-11-22", authenticator); discovery.SetServiceUrl("{url}"); QueryResponse queryResponse = null; service.Query( callback: (DetailedResponse<QueryResponse> response, IBMError error) => { Log.Debug("DiscoveryServiceV2", "Query result: {0}", response.Response); queryResponse = response.Result; }, projectId: "{project_id}", query: "{field}:{value}" ); while (queryResponse == null) yield return null;
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The remaining key-value pairs
results
Array of aggregations for the query.
An object contain retrieval type information.
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
Array of table results.
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
ResultMetadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
DocumentPassages
Results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
Aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
RetrievalDetails
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
The text used to filter.
SuggestedRefinements
Array of table results.
The identifier for the retrieved table.
The identifier of the document the table was retrieved from.
The identifier of the collection the table was retrieved from.
HTML snippet of the table info.
The offset of the table html snippet in the original document html.
Full table object retrieved from Table Understanding Enrichment.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
The textual contents of the current table from the input document without associated markup content.
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
SectionTitle
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
Title
An array of table-level cells that apply as headers to all the other cells in the current table.
The unique ID of the cell in the current table.
The location of the table header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of the cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
TableHeaders
An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current table.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
RowHeaders
An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the current table.
The unique ID of the cell in the current table.
The location of the column header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
ColumnHeaders
An array of key-value pairs identified in the current table.
A key in a key-value pair.
The unique ID of the key in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
The text content of the table cell without HTML markup.
Key
A list of values in a key-value pair.
The unique ID of the value in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
The text content of the table cell without HTML markup.
Value
KeyValuePairs
An array of cells that are neither table header nor column header nor row header cells, of the current table with corresponding row and column header associations.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
The textual contents of this cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.A list of table row header ids.
The
id
values of a row header.
RowHeaderIds
A list of table row header texts.
The
text
value of a row header.
RowHeaderTexts
A list of table row header texts normalized.
The normalized version of a row header text.
RowHeaderTextsNormalized
A list of table column header ids.
The
id
value of a column header.
ColumnHeaderIds
A list of table column header texts.
The
text
value of a column header.
ColumnHeaderTexts
A list of table column header texts normalized.
The normalized version of a column header text.
ColumnHeaderTextsNormalized
A list of document attributes.
The type of attribute.
The text associated with the attribute.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
Attributes
BodyCells
An array of lists of textual entries across the document related to the current table being parsed.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
Location
Contexts
Table
TableResults
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
resultMetadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
documentPassages
results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
retrievalDetails
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
The text used to filter.
suggestedRefinements
Array of table results.
The identifier for the retrieved table.
The identifier of the document the table was retrieved from.
The identifier of the collection the table was retrieved from.
HTML snippet of the table info.
The offset of the table html snippet in the original document html.
Full table object retrieved from Table Understanding Enrichment.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of the current table from the input document without associated markup content.
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
sectionTitle
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
title
An array of table-level cells that apply as headers to all the other cells in the current table.
The unique ID of the cell in the current table.
The location of the table header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of the cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
tableHeaders
An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current table.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
rowHeaders
An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the current table.
The unique ID of the cell in the current table.
The location of the column header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
columnHeaders
An array of key-value pairs identified in the current table.
A key in a key-value pair.
The unique ID of the key in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
key
A list of values in a key-value pair.
The unique ID of the value in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
value
keyValuePairs
An array of cells that are neither table header nor column header nor row header cells, of the current table with corresponding row and column header associations.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.A list of table row header ids.
The
id
values of a row header.
rowHeaderIds
A list of table row header texts.
The
text
value of a row header.
rowHeaderTexts
A list of table row header texts normalized.
The normalized version of a row header text.
rowHeaderTextsNormalized
A list of table column header ids.
The
id
value of a column header.
columnHeaderIds
A list of table column header texts.
The
text
value of a column header.
columnHeaderTexts
A list of table column header texts normalized.
The normalized version of a column header text.
columnHeaderTextsNormalized
A list of document attributes.
The type of attribute.
The text associated with the attribute.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
attributes
bodyCells
An array of lists of textual entries across the document related to the current table being parsed.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
contexts
table
tableResults
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
result_metadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
document_passages
results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
retrieval_details
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
The text used to filter.
suggested_refinements
Array of table results.
The identifier for the retrieved table.
The identifier of the document the table was retrieved from.
The identifier of the collection the table was retrieved from.
HTML snippet of the table info.
The offset of the table html snippet in the original document html.
Full table object retrieved from Table Understanding Enrichment.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of the current table from the input document without associated markup content.
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
section_title
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
title
An array of table-level cells that apply as headers to all the other cells in the current table.
The unique ID of the cell in the current table.
The location of the table header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of the cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
table_headers
An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current table.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
row_headers
An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the current table.
The unique ID of the cell in the current table.
The location of the column header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
column_headers
An array of key-value pairs identified in the current table.
A key in a key-value pair.
The unique ID of the key in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
key
A list of values in a key-value pair.
The unique ID of the value in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
value
key_value_pairs
An array of cells that are neither table header nor column header nor row header cells, of the current table with corresponding row and column header associations.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.A list of table row header ids.
The
id
values of a row header.
row_header_ids
A list of table row header texts.
The
text
value of a row header.
row_header_texts
A list of table row header texts normalized.
The normalized version of a row header text.
row_header_texts_normalized
A list of table column header ids.
The
id
value of a column header.
column_header_ids
A list of table column header texts.
The
text
value of a column header.
column_header_texts
A list of table column header texts normalized.
The normalized version of a column header text.
column_header_texts_normalized
A list of document attributes.
The type of attribute.
The text associated with the attribute.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
attributes
body_cells
An array of lists of textual entries across the document related to the current table being parsed.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
contexts
table
table_results
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
result_metadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
document_passages
results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
retrieval_details
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
The text used to filter.
suggested_refinements
Array of table results.
The identifier for the retrieved table.
The identifier of the document the table was retrieved from.
The identifier of the collection the table was retrieved from.
HTML snippet of the table info.
The offset of the table html snippet in the original document html.
Full table object retrieved from Table Understanding Enrichment.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of the current table from the input document without associated markup content.
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
section_title
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
title
An array of table-level cells that apply as headers to all the other cells in the current table.
The unique ID of the cell in the current table.
The location of the table header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of the cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
table_headers
An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current table.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
row_headers
An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the current table.
The unique ID of the cell in the current table.
The location of the column header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
column_headers
An array of key-value pairs identified in the current table.
A key in a key-value pair.
The unique ID of the key in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
key
A list of values in a key-value pair.
The unique ID of the value in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
value
key_value_pairs
An array of cells that are neither table header nor column header nor row header cells, of the current table with corresponding row and column header associations.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.A list of table row header ids.
The
id
values of a row header.
row_header_ids
A list of table row header texts.
The
text
value of a row header.
row_header_texts
A list of table row header texts normalized.
The normalized version of a row header text.
row_header_texts_normalized
A list of table column header ids.
The
id
value of a column header.
column_header_ids
A list of table column header texts.
The
text
value of a column header.
column_header_texts
A list of table column header texts normalized.
The normalized version of a column header text.
column_header_texts_normalized
A list of document attributes.
The type of attribute.
The text associated with the attribute.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
attributes
body_cells
An array of lists of textual entries across the document related to the current table being parsed.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
contexts
table
table_results
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
result_metadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
document_passages
results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
retrieval_details
Suggested correction to the submitted natural_language_query value.
Array of suggested refinments.
The text used to filter.
suggested_refinements
Array of table results.
The identifier for the retrieved table.
The identifier of the document the table was retrieved from.
The identifier of the collection the table was retrieved from.
HTML snippet of the table info.
The offset of the table html snippet in the original document html.
Full table object retrieved from Table Understanding Enrichment.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of the current table from the input document without associated markup content.
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
section_title
Text and associated location within a table.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
title
An array of table-level cells that apply as headers to all the other cells in the current table.
The unique ID of the cell in the current table.
The location of the table header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of the cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
table_headers
An array of row-level cells, each applicable as a header to other cells in the same row as itself, of the current table.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
row_headers
An array of column-level cells, each applicable as a header to other cells in the same column as itself, of the current table.
The unique ID of the cell in the current table.
The location of the column header cell in the current table as defined by its
begin
andend
offsets, respectfully, in the input document.The textual contents of this cell from the input document without associated markup content.
If you provide customization input, the normalized version of the cell text according to the customization; otherwise, the same value as
text
.The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.
column_headers
An array of key-value pairs identified in the current table.
A key in a key-value pair.
The unique ID of the key in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
key
A list of values in a key-value pair.
The unique ID of the value in the table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The text content of the table cell without HTML markup.
value
key_value_pairs
An array of cells that are neither table header nor column header nor row header cells, of the current table with corresponding row and column header associations.
The unique ID of the cell in the current table.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
The textual contents of this cell from the input document without associated markup content.
The
begin
index of this cell'srow
location in the current table.The
end
index of this cell'srow
location in the current table.The
begin
index of this cell'scolumn
location in the current table.The
end
index of this cell'scolumn
location in the current table.A list of table row header ids.
The
id
values of a row header.
row_header_ids
A list of table row header texts.
The
text
value of a row header.
row_header_texts
A list of table row header texts normalized.
The normalized version of a row header text.
row_header_texts_normalized
A list of table column header ids.
The
id
value of a column header.
column_header_ids
A list of table column header texts.
The
text
value of a column header.
column_header_texts
A list of table column header texts normalized.
The normalized version of a column header text.
column_header_texts_normalized
A list of document attributes.
The type of attribute.
The text associated with the attribute.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
attributes
body_cells
An array of lists of textual entries across the document related to the current table being parsed.
The text retrieved.
The numeric location of the identified element in the document, represented with two integers labeled
begin
andend
.The element's
begin
index.The element's
end
index.
location
contexts
table
table_results
A response containing the documents and aggregations for the query.
The number of matching results for the query.
Array of document results for the query.
The unique identifier of the document.
Metadata of the document.
Metadata of a query result.
The document retrieval source that produced this search result.
Possible values: [
search
,curation
]The collection id associated with this training data set.
The confidence score for the given result. Calculated based on how relevant the result is estimated to be. confidence can range from
0.0
to1.0
. The higher the number, the more relevant the document. Theconfidence
value for a result was calculated using the model specified in thedocument_retrieval_strategy
field of the result set. This field is only returned if the natural_language_query parameter is specified in the query.
resultMetadata
Passages returned by Discovery.
The content of the extracted passage.
The position of the first character of the extracted passage in the originating field.
The position of the last character of the extracted passage in the originating field.
The label of the field from which the passage has been extracted.
documentPassages
results
Array of aggregations for the query.
The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits.
aggregations
An object contain retrieval type information.
Indentifies the document retrieval strategy used for this query.
relevancy_training
indicates that the results were returned using a relevancy trained model.Note: In the event of trained collections being queried, but the trained model is not used to return results, the document_retrieval_strategy will be listed as
untrained
.Possible values: [
untrained
,relevancy_training
]
retrievalDetails
Suggested correction to the submitted natural_language_query value.