Class: IBMWatson::DiscoveryV2

Inherits:
IBMCloudSdkCore::BaseService
  • Object
show all
Includes:
Concurrent::Async
Defined in:
lib/ibm_watson/discovery_v2.rb

Overview

The Discovery V2 service.

Constant Summary collapse

DEFAULT_SERVICE_NAME =
"discovery"
DEFAULT_SERVICE_URL =
"https://api.us-south.discovery.watson.cloud.ibm.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ DiscoveryV2

Construct a new client for the Discovery service.

Parameters:

  • args (Hash)

    The args to initialize with

Options Hash (args):

  • version (String)

    Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is ‘2020-08-30`.

  • service_url (String)

    The base service URL to use when contacting the service. The base service_url may differ between IBM Cloud regions.

  • authenticator (Object)

    The Authenticator instance to be configured for this service.

  • service_name (String)

    The name of the service to configure. Will be used as the key to load any external configuration, if applicable.

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ibm_watson/discovery_v2.rb', line 51

def initialize(args = {})
  @__async_initialized__ = false
  defaults = {}
  defaults[:service_url] = DEFAULT_SERVICE_URL
  defaults[:service_name] = DEFAULT_SERVICE_NAME
  defaults[:authenticator] = nil
  defaults[:version] = nil
  user_service_url = args[:service_url] unless args[:service_url].nil?
  args = defaults.merge(args)
  @version = args[:version]
  raise ArgumentError.new("version must be provided") if @version.nil?

  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
  super
  @service_url = user_service_url unless user_service_url.nil?
end

Instance Attribute Details

#versionObject

Returns the value of attribute version.



38
39
40
# File 'lib/ibm_watson/discovery_v2.rb', line 38

def version
  @version
end

Instance Method Details

#add_document(project_id: , collection_id: , file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Add a document. Add a document to a collection with optional metadata.

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

  * The user must provide document content, metadata, or both. If the request is
missing both document content and metadata, it is rejected.

  * You can set the **Content-Type** parameter on the **file** part to indicate
the media type of the document. If the **Content-Type** parameter is missing or is
one of the generic media types (for example, `application/octet-stream`), then the
service attempts to automatically detect the document's media type.

  * The following field names are reserved and are filtered out if present after
normalization: `id`, `score`, `highlight`, and any field with the prefix of: `_`,
`+`, or `-`

  * Fields with empty name values after normalization are filtered out before
indexing.

  * Fields that contain the following characters after normalization are filtered
out before indexing: `#` and `,`

  If the document is uploaded to a collection that shares its data with another
collection, the **X-Watson-Discovery-Force** header must be set to `true`.

**Note:** You can assign an ID to a document that you add by appending the ID to
the endpoint
(`/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}`).
If a document already exists with the specified ID, it is replaced.

**Note:** This operation works with a file upload collection. It cannot be used to
modify a collection that crawls an external data source.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • file (File) (defaults to: nil)

    The content of the document to ingest. For maximum supported file size limits, see [the documentation](cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).

  • filename (String) (defaults to: nil)

    The filename for file.

  • file_content_type (String) (defaults to: nil)

    The content type of file.

  • metadata (String) (defaults to: nil)

    The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected.

    Example: “‘

    "Creator": "Johnny Appleseed",
    "Subject": "Apples"
    

    “‘.

  • x_watson_discovery_force (Boolean) (defaults to: nil)

    When ‘true`, the uploaded document is added to the collection even if the data for that collection is shared with other collections.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/ibm_watson/discovery_v2.rb', line 647

def add_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
    "X-Watson-Discovery-Force" => x_watson_discovery_force
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "add_document")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  form_data = {}

  unless file.nil?
    unless file.instance_of?(StringIO) || file.instance_of?(File)
      file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
    end
    filename = file.path if filename.nil? && file.respond_to?(:path)
    form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
  end

  form_data[:metadata] = HTTP::FormData::Part.new(.to_s, content_type: "text/plain") unless .nil?

  method_url = "/v2/projects/%s/collections/%s/documents" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    form: form_data,
    accept_json: true
  )
  response
end

#analyze_document(project_id: , collection_id: , file: nil, filename: nil, file_content_type: nil, metadata: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Analyze a Document. Process a document and return it for realtime use. Supports JSON files only.

The document is processed according to the collection's configuration settings but
is not stored in the collection.

**Note:** This method is supported on installed instances of Discovery only.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • file (File) (defaults to: nil)

    The content of the document to ingest. For maximum supported file size limits, see [the documentation](cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).

  • filename (String) (defaults to: nil)

    The filename for file.

  • file_content_type (String) (defaults to: nil)

    The content type of file.

  • metadata (String) (defaults to: nil)

    The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected.

    Example: “‘

    "Creator": "Johnny Appleseed",
    "Subject": "Apples"
    

    “‘.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
# File 'lib/ibm_watson/discovery_v2.rb', line 1094

def analyze_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "analyze_document")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  form_data = {}

  unless file.nil?
    unless file.instance_of?(StringIO) || file.instance_of?(File)
      file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
    end
    filename = file.path if filename.nil? && file.respond_to?(:path)
    form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
  end

  form_data[:metadata] = HTTP::FormData::Part.new(.to_s, content_type: "text/plain") unless .nil?

  method_url = "/v2/projects/%s/collections/%s/analyze" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    form: form_data,
    accept_json: true
  )
  response
end

#create_collection(project_id: , name: , description: nil, language: nil, enrichments: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Create a collection. Create a new collection in the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • name (String) (defaults to: )

    The name of the collection.

  • description (String) (defaults to: nil)

    A description of the collection.

  • language (String) (defaults to: nil)

    The language of the collection.

  • enrichments (Array[CollectionEnrichment]) (defaults to: nil)

    An array of enrichments that are applied to this collection.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/ibm_watson/discovery_v2.rb', line 116

def create_collection(project_id:, name:, description: nil, language: nil, enrichments: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("name must be provided") if name.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_collection")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "name" => name,
    "description" => description,
    "language" => language,
    "enrichments" => enrichments
  }

  method_url = "/v2/projects/%s/collections" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#create_enrichment(project_id: , enrichment: , file: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Create an enrichment. Create an enrichment for use with the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • enrichment (CreateEnrichment) (defaults to: )

    Information about a specific enrichment.

  • file (File) (defaults to: nil)

    The enrichment file to upload.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'lib/ibm_watson/discovery_v2.rb', line 1182

def create_enrichment(project_id:, enrichment:, file: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("enrichment must be provided") if enrichment.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_enrichment")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  form_data = {}

  form_data[:enrichment] = HTTP::FormData::Part.new(enrichment.to_s, content_type: "application/json")

  unless file.nil?
    unless file.instance_of?(StringIO) || file.instance_of?(File)
      file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
    end
    form_data[:file] = HTTP::FormData::File.new(file, content_type: "application/octet-stream", filename: file.respond_to?(:path) ? file.path : nil)
  end

  method_url = "/v2/projects/%s/enrichments" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    form: form_data,
    accept_json: true
  )
  response
end

#create_project(name: , type: , default_query_parameters: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Create a Project. Create a new project for this instance.

Parameters:

  • name (String) (defaults to: )

    The human readable name of this project.

  • type (String) (defaults to: )

    The type of project.

    The ‘content_intelligence` type is a *Document Retrieval for Contracts* project and the `other` type is a Custom project.

    The ‘content_mining` and `content_intelligence` types are available with Premium plan managed deployments and installed deployments only.

  • default_query_parameters (DefaultQueryParams) (defaults to: nil)

    Default query parameters for this project.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'lib/ibm_watson/discovery_v2.rb', line 1388

def create_project(name:, type:, default_query_parameters: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("name must be provided") if name.nil?

  raise ArgumentError.new("type must be provided") if type.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_project")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "name" => name,
    "type" => type,
    "default_query_parameters" => default_query_parameters
  }

  method_url = "/v2/projects"

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#create_training_query(project_id: , natural_language_query: , examples: , filter: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Create training query. Add a query to the training data for this project. The query can contain a filter

and natural language query.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • natural_language_query (String) (defaults to: )

    The natural text query for the training query.

  • examples (Array[TrainingExample]) (defaults to: )

    Array of training examples.

  • filter (String) (defaults to: nil)

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

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/ibm_watson/discovery_v2.rb', line 903

def create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?

  raise ArgumentError.new("examples must be provided") if examples.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "create_training_query")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "natural_language_query" => natural_language_query,
    "examples" => examples,
    "filter" => filter
  }

  method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#delete_collection(project_id: , collection_id: ) ⇒ nil

Delete a collection. Deletes the specified collection from the project. All documents stored in the

specified collection and not shared is also deleted.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

Returns:

  • (nil)

Raises:

  • (ArgumentError)


243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/ibm_watson/discovery_v2.rb', line 243

def delete_collection(project_id:, collection_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_collection")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#delete_document(project_id: , collection_id: , document_id: , x_watson_discovery_force: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Delete a document. If the given document ID is invalid, or if the document is not found, then the a

success response is returned (HTTP status code `200`) with the status set to
'deleted'.

**Note:** This operation only works on collections created to accept direct file
uploads. It cannot be used to modify a collection that connects to an external
source such as Microsoft SharePoint.

**Note:** Segments of an uploaded document cannot be deleted individually. Delete
all segments by deleting using the `parent_document_id` of a segment result.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • document_id (String) (defaults to: )

    The ID of the document.

  • x_watson_discovery_force (Boolean) (defaults to: nil)

    When ‘true`, the uploaded document is added to the collection even if the data for that collection is shared with other collections.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/ibm_watson/discovery_v2.rb', line 791

def delete_document(project_id:, collection_id:, document_id:, x_watson_discovery_force: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  raise ArgumentError.new("document_id must be provided") if document_id.nil?

  headers = {
    "X-Watson-Discovery-Force" => x_watson_discovery_force
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_document")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]

  response = request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#delete_enrichment(project_id: , enrichment_id: ) ⇒ nil

Delete an enrichment. Deletes an existing enrichment from the specified project.

**Note:** Only enrichments that have been manually created can be deleted.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • enrichment_id (String) (defaults to: )

    The ID of the enrichment.

Returns:

  • (nil)

Raises:

  • (ArgumentError)


1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
# File 'lib/ibm_watson/discovery_v2.rb', line 1314

def delete_enrichment(project_id:, enrichment_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_enrichment")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#delete_project(project_id: ) ⇒ nil

Delete a project. Deletes the specified project.

**Important:** Deleting a project deletes everything that is part of the specified
project, including all collections.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (nil)

Raises:

  • (ArgumentError)


1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
# File 'lib/ibm_watson/discovery_v2.rb', line 1505

def delete_project(project_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_project")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#delete_training_queries(project_id: ) ⇒ nil

Delete training queries. Removes all training queries for the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (nil)

Raises:

  • (ArgumentError)


865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
# File 'lib/ibm_watson/discovery_v2.rb', line 865

def delete_training_queries(project_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_training_queries")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#delete_training_query(project_id: , query_id: ) ⇒ nil

Delete a training data query. Removes details from a training data query, including the query string and all

examples.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • query_id (String) (defaults to: )

    The ID of the query used for training.

Returns:

  • (nil)

Raises:

  • (ArgumentError)


1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
# File 'lib/ibm_watson/discovery_v2.rb', line 1037

def delete_training_query(project_id:, query_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("query_id must be provided") if query_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_training_query")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#delete_user_data(customer_id: ) ⇒ nil

Delete labeled data. Deletes all data associated with a specified customer ID. The method has no effect

if no data is associated with the customer ID.

You associate a customer ID with data by passing the **X-Watson-Metadata** header
with a request that passes data. For more information about personal data and
customer IDs, see [Information
security](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-information-security#information-security).

**Note:** This method is only supported on IBM Cloud instances of Discovery.

Parameters:

  • customer_id (String) (defaults to: )

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

Returns:

  • (nil)

Raises:

  • (ArgumentError)


1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'lib/ibm_watson/discovery_v2.rb', line 1549

def delete_user_data(customer_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("customer_id must be provided") if customer_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_user_data")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version,
    "customer_id" => customer_id
  }

  method_url = "/v2/user_data"

  request(
    method: "DELETE",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: false
  )
  nil
end

#get_autocompletion(project_id: , prefix: , collection_ids: nil, field: nil, count: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Get Autocomplete Suggestions. Returns completion query suggestions for the specified prefix.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • prefix (String) (defaults to: )

    The prefix to use for autocompletion. For example, the prefix ‘Ho` could autocomplete to `hot`, `housing`, or `how`.

  • collection_ids (Array[String]) (defaults to: nil)

    Comma separated list of the collection IDs. If this parameter is not specified, all collections in the project are used.

  • field (String) (defaults to: nil)

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

  • count (Fixnum) (defaults to: nil)

    The number of autocompletion suggestions to return.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/ibm_watson/discovery_v2.rb', line 376

def get_autocompletion(project_id:, prefix:, collection_ids: nil, field: nil, count: nil)
  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("prefix must be provided") if prefix.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_autocompletion")
  headers.merge!(sdk_headers)
  collection_ids *= "," unless collection_ids.nil?

  params = {
    "version" => @version,
    "prefix" => prefix,
    "collection_ids" => collection_ids,
    "field" => field,
    "count" => count
  }

  method_url = "/v2/projects/%s/autocompletion" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#get_collection(project_id: , collection_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

Get collection. Get details about the specified collection.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/ibm_watson/discovery_v2.rb', line 160

def get_collection(project_id:, collection_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_collection")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#get_component_settings(project_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

List component settings. Returns default configuration settings for components.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/ibm_watson/discovery_v2.rb', line 564

def get_component_settings(project_id:)
  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("version must be provided") if version.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_component_settings")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/component_settings" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#get_enrichment(project_id: , enrichment_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

Get enrichment. Get details about a specific enrichment.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • enrichment_id (String) (defaults to: )

    The ID of the enrichment.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
# File 'lib/ibm_watson/discovery_v2.rb', line 1230

def get_enrichment(project_id:, enrichment_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_enrichment")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#get_project(project_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

Get project. Get details on the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
# File 'lib/ibm_watson/discovery_v2.rb', line 1430

def get_project(project_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_project")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#get_training_query(project_id: , query_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

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

examples.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • query_id (String) (defaults to: )

    The ID of the query used for training.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
# File 'lib/ibm_watson/discovery_v2.rb', line 949

def get_training_query(project_id:, query_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("query_id must be provided") if query_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_training_query")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#list_collections(project_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

List collections. Lists existing collections for the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/ibm_watson/discovery_v2.rb', line 79

def list_collections(project_id:)
  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("version must be provided") if version.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_collections")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/collections" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#list_enrichments(project_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

List Enrichments. Lists the enrichments available to this project. The *Part of Speech* and

*Sentiment of Phrases* enrichments might be listed, but are reserved for internal
use only.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
# File 'lib/ibm_watson/discovery_v2.rb', line 1147

def list_enrichments(project_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_enrichments")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/enrichments" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#list_fields(project_id: , collection_ids: nil) ⇒ IBMCloudSdkCore::DetailedResponse

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

collections.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_ids (Array[String]) (defaults to: nil)

    Comma separated list of the collection IDs. If this parameter is not specified, all collections in the project are used.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/ibm_watson/discovery_v2.rb', line 526

def list_fields(project_id:, collection_ids: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_fields")
  headers.merge!(sdk_headers)
  collection_ids *= "," unless collection_ids.nil?

  params = {
    "version" => @version,
    "collection_ids" => collection_ids
  }

  method_url = "/v2/projects/%s/fields" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#list_projectsIBMCloudSdkCore::DetailedResponse

List projects. Lists existing projects for this instance.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/ibm_watson/discovery_v2.rb', line 1350

def list_projects
  raise ArgumentError.new("version must be provided") if version.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_projects")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects"

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#list_training_queries(project_id: ) ⇒ IBMCloudSdkCore::DetailedResponse

List training queries. List the training queries for the specified project.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
# File 'lib/ibm_watson/discovery_v2.rb', line 832

def list_training_queries(project_id:)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_training_queries")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  method_url = "/v2/projects/%s/training_data/queries" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#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) ⇒ IBMCloudSdkCore::DetailedResponse

Query a project. By using this method, you can construct queries. For details, see the [Discovery

documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts).
The default query parameters are defined by the settings for this project, see the
[Discovery
documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-project-defaults)
for an overview of the standard default settings, and see [the Projects API
documentation](#create-project) for details about how to set custom default query
settings.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_ids (Array[String]) (defaults to: nil)

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

  • filter (String) (defaults to: nil)

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

  • query (String) (defaults to: nil)

    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.

  • natural_language_query (String) (defaults to: nil)

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

  • aggregation (String) (defaults to: nil)

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

  • count (Fixnum) (defaults to: nil)

    Number of results to return.

  • _return (Array[String]) (defaults to: nil)

    A list of the fields in the document hierarchy to return. If this parameter is an empty list, then all fields are returned.

  • offset (Fixnum) (defaults to: nil)

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

  • sort (String) (defaults to: nil)

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

  • highlight (Boolean) (defaults to: nil)

    When ‘true`, a highlight field is returned for each result which contains the fields which match the query with “ tags around the matching query terms.

  • spelling_suggestions (Boolean) (defaults to: nil)

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

  • table_results (QueryLargeTableResults) (defaults to: nil)

    Configuration for table retrieval.

  • suggested_refinements (QueryLargeSuggestedRefinements) (defaults to: nil)

    Configuration for suggested refinements. Available with Premium plans only.

  • passages (QueryLargePassages) (defaults to: nil)

    Configuration for passage retrieval.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/ibm_watson/discovery_v2.rb', line 318

def 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)
  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("version must be provided") if version.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "collection_ids" => collection_ids,
    "filter" => filter,
    "query" => query,
    "natural_language_query" => natural_language_query,
    "aggregation" => aggregation,
    "count" => count,
    "return" => _return,
    "offset" => offset,
    "sort" => sort,
    "highlight" => highlight,
    "spelling_suggestions" => spelling_suggestions,
    "table_results" => table_results,
    "suggested_refinements" => suggested_refinements,
    "passages" => passages
  }

  method_url = "/v2/projects/%s/query" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#query_collection_notices(project_id: , collection_id: , filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Query collection notices. Finds collection-level notices (errors and warnings) that are generated when

documents are ingested.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • filter (String) (defaults to: nil)

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

  • query (String) (defaults to: nil)

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

  • natural_language_query (String) (defaults to: nil)

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

  • count (Fixnum) (defaults to: nil)

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

  • offset (Fixnum) (defaults to: nil)

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

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/ibm_watson/discovery_v2.rb', line 431

def query_collection_notices(project_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query_collection_notices")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version,
    "filter" => filter,
    "query" => query,
    "natural_language_query" => natural_language_query,
    "count" => count,
    "offset" => offset
  }

  method_url = "/v2/projects/%s/collections/%s/notices" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#query_notices(project_id: , filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Query project notices. Finds project-level notices (errors and warnings). Currently, project-level

notices are generated by relevancy training.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • filter (String) (defaults to: nil)

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

  • query (String) (defaults to: nil)

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

  • natural_language_query (String) (defaults to: nil)

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

  • count (Fixnum) (defaults to: nil)

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

  • offset (Fixnum) (defaults to: nil)

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

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/ibm_watson/discovery_v2.rb', line 485

def query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query_notices")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version,
    "filter" => filter,
    "query" => query,
    "natural_language_query" => natural_language_query,
    "count" => count,
    "offset" => offset
  }

  method_url = "/v2/projects/%s/notices" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "GET",
    url: method_url,
    headers: headers,
    params: params,
    accept_json: true
  )
  response
end

#update_collection(project_id: , collection_id: , name: nil, description: nil, enrichments: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Update a collection. Updates the specified collection’s name, description, and enrichments.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • name (String) (defaults to: nil)

    The name of the collection.

  • description (String) (defaults to: nil)

    A description of the collection.

  • enrichments (Array[CollectionEnrichment]) (defaults to: nil)

    An array of enrichments that are applied to this collection.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/ibm_watson/discovery_v2.rb', line 199

def update_collection(project_id:, collection_id:, name: nil, description: nil, enrichments: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_collection")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "name" => name,
    "description" => description,
    "enrichments" => enrichments
  }

  method_url = "/v2/projects/%s/collections/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#update_document(project_id: , collection_id: , document_id: , file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Update a document. Replace an existing document or add a document with a specified document_id.

Starts ingesting a document with optional metadata.

If the document is uploaded to a collection that shares its data with another
collection, the **X-Watson-Discovery-Force** header must be set to `true`.

**Note:** When uploading a new document with this method it automatically replaces
any document stored with the same **document_id** if it exists.

**Note:** This operation only works on collections created to accept direct file
uploads. It cannot be used to modify a collection that connects to an external
source such as Microsoft SharePoint.

**Note:** If an uploaded document is segmented, all segments are overwritten, even
if the updated version of the document has fewer segments.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • collection_id (String) (defaults to: )

    The ID of the collection.

  • document_id (String) (defaults to: )

    The ID of the document.

  • file (File) (defaults to: nil)

    The content of the document to ingest. For maximum supported file size limits, see [the documentation](cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#collections-doc-limits).

  • filename (String) (defaults to: nil)

    The filename for file.

  • file_content_type (String) (defaults to: nil)

    The content type of file.

  • metadata (String) (defaults to: nil)

    The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected.

    Example: “‘

    "Creator": "Johnny Appleseed",
    "Subject": "Apples"
    

    “‘.

  • x_watson_discovery_force (Boolean) (defaults to: nil)

    When ‘true`, the uploaded document is added to the collection even if the data for that collection is shared with other collections.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'lib/ibm_watson/discovery_v2.rb', line 727

def update_document(project_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("collection_id must be provided") if collection_id.nil?

  raise ArgumentError.new("document_id must be provided") if document_id.nil?

  headers = {
    "X-Watson-Discovery-Force" => x_watson_discovery_force
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_document")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  form_data = {}

  unless file.nil?
    unless file.instance_of?(StringIO) || file.instance_of?(File)
      file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
    end
    filename = file.path if filename.nil? && file.respond_to?(:path)
    form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
  end

  form_data[:metadata] = HTTP::FormData::Part.new(.to_s, content_type: "text/plain") unless .nil?

  method_url = "/v2/projects/%s/collections/%s/documents/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id), ERB::Util.url_encode(document_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    form: form_data,
    accept_json: true
  )
  response
end

#update_enrichment(project_id: , enrichment_id: , name: , description: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Update an enrichment. Updates an existing enrichment’s name and description.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • enrichment_id (String) (defaults to: )

    The ID of the enrichment.

  • name (String) (defaults to: )

    A new name for the enrichment.

  • description (String) (defaults to: nil)

    A new description for the enrichment.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
# File 'lib/ibm_watson/discovery_v2.rb', line 1268

def update_enrichment(project_id:, enrichment_id:, name:, description: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?

  raise ArgumentError.new("name must be provided") if name.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_enrichment")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "name" => name,
    "description" => description
  }

  method_url = "/v2/projects/%s/enrichments/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(enrichment_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#update_project(project_id: , name: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Update a project. Update the specified project’s name.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • name (String) (defaults to: nil)

    The new name to give this project.

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/ibm_watson/discovery_v2.rb', line 1464

def update_project(project_id:, name: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_project")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "name" => name
  }

  method_url = "/v2/projects/%s" % [ERB::Util.url_encode(project_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end

#update_training_query(project_id: , query_id: , natural_language_query: , examples: , filter: nil) ⇒ IBMCloudSdkCore::DetailedResponse

Update a training query. Updates an existing training query and it’s examples.

Parameters:

  • project_id (String) (defaults to: )

    The ID of the project. This information can be found from the *Integrate and Deploy* page in Discovery.

  • query_id (String) (defaults to: )

    The ID of the query used for training.

  • natural_language_query (String) (defaults to: )

    The natural text query for the training query.

  • examples (Array[TrainingExample]) (defaults to: )

    Array of training examples.

  • filter (String) (defaults to: nil)

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

Returns:

  • (IBMCloudSdkCore::DetailedResponse)

    A ‘IBMCloudSdkCore::DetailedResponse` object representing the response.

Raises:

  • (ArgumentError)


989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File 'lib/ibm_watson/discovery_v2.rb', line 989

def update_training_query(project_id:, query_id:, natural_language_query:, examples:, filter: nil)
  raise ArgumentError.new("version must be provided") if version.nil?

  raise ArgumentError.new("project_id must be provided") if project_id.nil?

  raise ArgumentError.new("query_id must be provided") if query_id.nil?

  raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?

  raise ArgumentError.new("examples must be provided") if examples.nil?

  headers = {
  }
  sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "update_training_query")
  headers.merge!(sdk_headers)

  params = {
    "version" => @version
  }

  data = {
    "natural_language_query" => natural_language_query,
    "examples" => examples,
    "filter" => filter
  }

  method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]

  response = request(
    method: "POST",
    url: method_url,
    headers: headers,
    params: params,
    json: data,
    accept_json: true
  )
  response
end