vania-janet/multiturn-rag-retrieval-data huggingface dataset:
The _rev field is a revision identifier, and is [essential to the IBM Cloudant replication protocol](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-document-versioning-and-mvccdocument-versioning-and-mvcc).



In addition to these two mandatory fields, documents can generally contain any other content that can be described by using JSON, subject to some caveats detailed in the following sections.



 Document IDs 

The format of a document ID differs depending on whether a database is partitioned or not. When a database is partitioned, the partition key for each document is defined as part of the document ID as detailed in the next section.



 IDs in partitioned databases 

When you use a partitioned database, the document ID specifies both the partition key and the document key. These keys are specified by splitting the document ID into two parts that are separated by a colon:

$PARTITION_KEY:$DOCUMENT_KEY

The $PARTITION_KEY might be the same between documents. The $DOCUMENT_KEY must be unique within each partition. That is, overall the entire document ID must be unique within a database. A document key might contain further colon characters.





 IDs in non-partitioned databases 

For non-partitioned databases, the _id field is either created by you, or generated automatically as a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) by IBM Cloudant.

If you choose to specify the document _id field, it must be limited to no more than 7168 characters (7k).

As with partitioned databases, the document ID must be unique within a database.







 Field name restrictions 

Field names that begin with the underscore character (_) are reserved in IBM Cloudant. This rule means that you can't normally have your own field names that begin with an underscore. For example, the field example would be accepted, but the field _example would result in a doc_validation error message.

See an example of a JSON document that attempts to create a field with an underscore prefix:

{
Selector syntax 

The IBM® Cloudant® for IBM Cloud® Query language is expressed as a JSON object that describes documents of interest. Within this structure, you can apply conditional logic by using specially named fields.

The IBM Cloudant Query language has some similarities with MongoDB query documents, but these similarities arise from a commonality of purpose and don't necessarily extend to equivalence of function or result.



 Selector basics 

Elementary selector syntax requires you to specify one or more fields, and the corresponding values needed for those fields. The following example selector matches all documents that have a director field that contains the value Lars von Trier.

See the following example of a simple selector:

{
"selector": {
"director": "Lars von Trier"
}
}

If you created a full text index by specifying "type":"text" when the index was created, you can use the $text operator to select matching documents. In the following example, the full text index is inspected to find any document that contains the word Bond.

See the following example of a simple selector for a full_text index:

{
"selector": {
"$text": "Bond"
}
}

You can create more complex selector expressions by combining operators. However, for IBM Cloudant Query indexes of type json, you can't use "combination" or "array logical" operators such as $regex as the basis of a query. Only the equality operators such as $eq, $gt, $gte, $lt, and $lte - but not$ne - can be used as the basis of a more complex query. For more information about creating complex selector expressions, see [Creating selector expressions](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-selector-syntaxcreating-selector-expressions).





 Selector with two fields 

In the following example, the selector matches any document with a name field that contains Paul, and that also has a location field with the value "Boston".

See the following example of a more complex selector:

{
"selector": {
"name": "Paul",
"location": "Boston"
}
fmt.Println(string(b))

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
"github.com/IBM/go-sdk-core/v5/core"
)

All Go examples require the service object to be initialized. For more information, see the API documentation's [Authentication section](https://cloud.ibm.com/apidocs/cloudant?code=goauthentication-with-external-configuration) for examples.









 Making queries 

Overall, you want to make four queries:



1. Readings for all time for a piece of infrastructure.
2. Readings for today for a piece of infrastructure.
3. Readings for all time for a specific device.
4. Readings for today for a specific device.





 Finding all readings for a piece of infrastructure 

These partitions are infrastructure-based, so you can use _all_docs for a partition. For example, query all readings for the bridge-9876 infrastructure piece by using the following command.



* Curl
* Java
* Node
* Python
* Go



curl -X POST "$SERVICE_URL/readings/_partition/bridge-9876/_all_docs" -H 'Content-Type:
application/json' --data '{"include_docs": true}'

import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.AllDocsResult;
import com.ibm.cloud.cloudant.v1.model.PostPartitionAllDocsOptions;
Cloudant service = Cloudant.newInstance();

PostPartitionAllDocsOptions allDocsOptions =
new PostPartitionAllDocsOptions.Builder()
.db("readings")
.partitionKey("bridge-9876")
queries: allDocsQueries
}).then(response => {
console.log(response.result);
});

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)

All Go examples require the service object to be initialized. For more information, see the API documentation's [Authentication section](https://cloud.ibm.com/apidocs/cloudant?code=goauthentication-with-external-configuration) for examples.

If you POST to the _all_docs/queries endpoint, it runs multiple specified built-in view queries of all documents in this database. You can use this endpoint to request multiple queries in a single request, instead of multiple POST /$DATABASE/_all_docs requests.

The request JSON object must have a queries field. It represents an array of query objects with fields for the parameters of each individual view query to be run. The field names and their meaning are the same as the query parameters of a regular _all_docs request.

The results are returned by using the following response JSON object:



Table 1. Response JSON object

 Response JSON object Description Type 

 results An array of result objects - one for each query. Each result object contains the same fields as the response to a regular _all_docs request. Array 



See the following example request with multiple queries:

{POST /db/_all_docs/queries HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:5984

{
"queries": [
{
"keys":
"meatballs",
"spaghetti"
]
},
{
"limit": 3,
"skip": 2
}
]
}
Show more

See the following example response for multiple queries:
When you create a new IBM Cloudant instance from the command line, you must include the ibmcloud tool by using the -p parameter. This parameter enables or disables legacy credentials for an account by passing the option in JSON format. The option is called legacyCredentials.

To create an instance as Use only IAM, run the following command:

ibmcloud resource service-instance-create "Instance Name" cloudantnosqldb Standard us-south -p '{"legacyCredentials": false}'

If you don't use Use only IAM mode when you use the IAM Reader and Writer roles, you might grant users legacy credentials with more access permissions than you intended.





 How can I generate service credentials? 

You can generate service credentials in the primary IBM Cloud IAM interface. When you select Use only IAM, service credentials include only IAM values. The service credential JSON looks like the following example:

{
"apikey": "MxVp86XHkU82Wc97tdvDF8qM8B0Xdit2RqR1mGfVXPWz",
"host": "2922d728-27c0-4c7f-aa80-1e59fbeb04d0-bluemix.cloudant.com",
"iam_apikey_description": "Auto generated apikey during resource-key [...]",
"iam_apikey_name": "auto-generated-apikey-050d21b5-5f[...]",
"iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",
"iam_serviceid_crn": "crn:v1:staging:public:iam-identity::[...]",
"url": "https://76838001-b883-444d-90d0-46f89e942a15-bluemix.cloudant.com",
To disable IBM Cloudant security, PUT a JSON document to the _security endpoint of the database. For example, https://$ACCOUNT.cloudant.com/$DATABASE/_security.

See the following example that uses HTTP to submit a modification request:

PUT /$DATABASE/_security HTTP/1.1
Content-Type: application/json

See the following example to submit a modification request:



* Curl
* Java
* Python
* Go
* Node



curl -H "Authorization: Bearer $API_BEARER_TOKEN" -X PUT "$SERVICE_URL/products/_security" -H "Content-Type: application/json" --data '{"members": {"names": ["user1", "user2"], "roles": ["developers"]}}'

import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.Ok;
import com.ibm.cloud.cloudant.v1.model.PutSecurityOptions;
import com.ibm.cloud.cloudant.v1.model.SecurityObject;

import java.util.Arrays;

Cloudant service = Cloudant.newInstance();

SecurityObject members = new SecurityObject.Builder()
.names(Arrays.asList("user1", "user2"))
.roles(Arrays.asList("developers"))
.build();

PutSecurityOptions securityOptions =
new PutSecurityOptions.Builder()
.db("products")
.members(members)
.build();

Ok response =
service.putSecurity(securityOptions).execute()
.getResult();

System.out.println(response);

from ibmcloudant.cloudant_v1 import CloudantV1, SecurityObject

service = CloudantV1.new_instance()

members = SecurityObject(
names=['user1', 'user2'],
API endpoint: https://cloud.ibm.com

Email> J.Doe@email.com

Password>

IBM Cloud validates your details and summarizes the information about your login session.

API endpoint: https://cloud.ibm.com

Email> J.Doe@email.com

Password>
Authenticating...
OK

Targeted account J DOE's Account (707...a32)

Targeted org J.Doe@email.com

Targeted space dev

API endpoint: https://cloud.ibm.com (API version: 2.54.0)
Region: au-syd
User: j.doe@email.com
Account: J DOE's Account (707...a32)
Org: J.Doe@email.com
Space: dev
Show more
3. You're now logged in to your IBM Cloud account.







 Step 2: Creating the IBM Cloudant service 

IBM Cloudant uses resource groups for provisioning new instances. For more information, see the [Resource Groups FAQ](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-faq-ibm-cloud-resource-groups).

In this example, you create a service instance within IBM Cloud by running the following command.

ibmcloud resource service-instance-create NAME SERVICE_NAME SERVICE_PLAN_NAME LOCATION [-p, --parameters @JSON_FILE | JSON_STRING ]

The fields in the command are described in the table that follows.



Table 1. Basic command format fields

 Field Description 

 NAME Arbitrary name that you give to the instance. 
 SERVICE_NAME cloudantnosqldb 
 SERVICE_PLAN_NAME Lite plan (lite) or Standard plan (standard) 
 LOCATION The location where you want to deploy includes the following cities: Sydney au-syd, Chennai in-che, Osaka jp-osa, Tokyo jp-tok, Seoul kr-seo, Frankfurt eu-de, London eu-gb, Dallas us-south, Washington DC us-east. 
 legacyCredentials Defaults to true.
Workspace transactional data is encrypted using the DEKs, including logs and the Terraform tf.state file at rest. The encrypted data stored in an IBM Cloud Object Storage bucket .
7. Workspace operational data, workspace and job names, pointers to user data in IBM Cloud Object Storage and search keys, are stored in IBM Cloudant. All information stored in Cloudant is encrypted with AES 256. For more information on Cloudant data security and encryption, see [Cloudant Security](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-security).







 How can I delete my information? 

To remove your data from IBM Cloud Schematics, choose among the following options:



* Delete the workspace: When you delete your workspace, all the data related to the workspace is permanently deleted.
* Open an IBM Cloud support case: Contact IBM Support to remove your workspaces and any associated data by opening a support case. For more information, see [Getting support](https://cloud.ibm.com/docs/get-support?topic=get-support-using-avatar).
* End your IBM Cloud subscription: A Schematics cleanup job runs multiple times a day to verify that all workspaces that are stored by IBM belong to an active IBM Cloud account. If no active account is found, the workspace and all associated stored data is deleted.
If JSON is not specified, output will be returned in a tabular format.

help | --help | -h
: List options available for the command.







 ibmcloud atracker target update (Event Streams) 

Use this command to update an Event Streams target for an IBM Cloud Activity Tracker Event Routing region. Any specified value that is different from when the target was originally created will be updated to the value specified in the command.

ibmcloud atracker target update --target TARGET [--name TARGET_NAME] [ --file EVENTSTREAMS_ENDPOINT_DEFINITION_JSON_FILE] | ( --brokers BROKER_LIST] --target-crn EVENTSTREAMS_TARGET_CRN] --topic TOPIC]( --api-key ( EVENTSTREAMS_API_KEY | @EVENTSTREAMS_API_KEY_FILE )]))] [--output FORMAT]



 Command options 

--region REGION | -r REGION
: Name of the region, for example, us-south or eu-gb. If not specified, the region logged into, or targeted, will be used.

--name TARGET_NAME
: The name to be given to the target.

Do not include any personal identifying information (PII) in any resource names.

--type TARGET_TYPE
: Set the TARGET_TYPE to cloud_object_storage for a COS target.

--file @EVENTSTREAMS_ENDPOINT_DEFINITION_JSON_FILE
: A file containing an endpoint definition in the following format:

{
"target_crn": "yyyyy",
"brokers": ["broker-1:9093","broker-2:9093"],
"topic": "my-topic",
"api_key": "xxxxxxxxxxxxxx"
}

--target-crn[EVENTSTREAMS_TARGET_CRN](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-connecting)[
: The CRN of the IBM® Event Streams for IBM Cloud® instance.
Copy and paste the following index definition:

{
"index": {
"fields": [
"publisher", "year"
]
},
"name": "publisher-year-index",indexingdashboard5
"type": "json"
}

See an example in the following screen capture:

Zoom

![Click Create index to create an index.](https://cloud.ibm.com/docs-content/v1/content/522c6f62358b063f921283400a601c3f9bc66f08/Cloudant/images/indexingdashboard2.png)

Figure 2. Window for creating indexes



The fields array contains a list of fields that we want IBM Cloudant to index.

If we repeat our query, it is faster and remains quick even as the database size reaches millions of documents.

Indexing instructs IBM Cloudant to create a secondary data structure that allows it to find the slice of data you need much faster than looking over every document in turn. IBM Cloudant Query is best for fixed queries based on the same fields in the same order.

For more information, see the following details in IBM Cloudant documentation:



* [Optimizing IBM Cloudant Queries](https://blog.cloudant.com/2020/04/24/Optimising-Cloudant-Queries.html)
* [IBM Cloudant Query documentation](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-query)



This index is useful for queries that involve both the publisher and the year, but if we introduce another field or make the query more complex (for example, by using the $or operator), then the index doesn't get used. We are back to a full database scan.

For a general-purpose search facility, we need IBM Cloudant Search, which is described in the next section.







 Step 3. Creating a search engine - IBM Cloudant Search 

IBM Cloudant Search is based on Apache Lucene and has its own query language that allows rich queries to be constructed.
* IBM Cloudant provides an array of 10 IBM Cloudant documents and a bookmark, an opaque key that represents a pointer to the next documents in the result set. * When the next set of results is required, the search is repeated. However, the query is sent, with the bookmark from the first response, to IBM Cloudant in the request. * IBM Cloudant replies with the second set of documents and another bookmark, which can be used to get a third page of results. * Repeat<-- </ul> -->Now you can see how to do that with code.<-- </section "id="section-how-do-cloudant-bookmarks-work" "> --><-- <section "id="section-use-cloudant-query-search" "> --> How can I use IBM Cloudant Query to search? First, you search for all the cities in the US. You're using IBM Cloudant Query]IBM Cloudant Query 1] , so the operation is specified as a block of JSON: {
"selector": {
"$eq": {
"country": "US"
}
},
"limit": 5
}
By using the /db/_find]IBM Cloudant Query] ! ! API endpoint, the results are passed to IBM Cloudant.<-- <ul> --> * Curl * Java * Node * Python * Go<-- </ul> --> curl -X POST -H "Authorization: Bearer $API_BEARER_TOKEN" -H 'Content-type: application/json' -d '{"selector":{"country":{"$eq": "US"}},"limit":5}' "$SERVICE_URL/cities/_find"
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.FindResult;
import com.ibm.cloud.cloudant.v1.model.PostFindOptions;

import java.util.Collections;
import java.util.Map;
ibmcloud is bare-metal-server-disk SERVER SERVER_DISK [--output JSON] [-q, --quiet]



 Command options 



* SERVER: ID or name of the server.
* SERVER_DISK: ID or name of the server disk.
* --output: Specify output format, only JSON is supported. One of: JSON.
* -q, --quiet: Suppress verbose output.



--------------------







 ibmcloud is bare-metal-server-disk-update 

Update a bare metal server disk.

ibmcloud is bare-metal-server-disk-update SERVER SERVER_DISK --name NEW_NAME [--output JSON] [-q, --quiet]



 Command options 



* SERVER: ID or name of the server.
* SERVER_DISK: ID or name of the server disk.
* --name: New name of local disk.
* --output: Specify output format, only JSON is supported. One of: JSON.
* -q, --quiet: Suppress verbose output.



--------------------







 ibmcloud is bare-metal-server-disks 

List all disks of a bare metal server.

ibmcloud is bare-metal-server-disks SERVER [--output JSON] [-q, --quiet]



 Command options 



* SERVER: ID or name of the server.
* --output: Specify output format, only JSON is supported. One of: JSON.
* -q, --quiet: Suppress verbose output.



--------------------







 ibmcloud is bare-metal-server-initialization-values 

Retrieve configuration variables that are used to initialize the bare metal server.
Then, you can download, scan, and re-upload the object.
* Is it possible to form a Hadoop cluster using Object Storage?

No, Object Storage is used for the object storage service. For a Hadoop cluster, you need the processing associated with each unit of storage. You may consider the Hadoop-as-a-Service setup.
* Can I generate a "Presigned URL" to download a file and review?

A PreSigned URL is not generated using the IBM Cloud UI; however, you can use CyberDuck to generate the “pre-signed URL”. It is free. For details, see this [Slack channel](https://ibm-cloudplatform.slack.com/archives/C0VJSU370/p1606859253294800).
* How can I generate a Auth Token using the IAM API Key using REST?

For more information on working with the API, see [Creating IAM token for API Key](https://cloud.ibm.com/docs/account?topic=account-iamtoken_from_apikey) and [Congfiguration Authentication](https://cloud.ibm.com/apidocs/cos/cos-configurationauthentication).
* How can I use the Object Storage web console to download and upload large objects?

You can use IBM Cloud CLI or the API to download large objects. Alternatively, plugins such as Aspera /rclone can be used.
* What are the libraries that the Object Storage SDK supports?

Object Storage provides SDKs for Java, Python, NodeJS, and Go featuring capabilities to make the most of IBM Cloud Object Storage. For information about the features supported by each SDK, see the [feature list](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-sdk-about).
* When a file is uploaded to a cross region bucket using the ‘us-geo’ endpoint, how long is the delay before the file is available at the other US sites?
db='orders',
include_docs=True,
keys=['somekey', 'someotherkey'],
limit=10
).get_result()

print(response)

postAllDocsOptions := service.NewPostAllDocsOptions(
"orders",
)
postAllDocsOptions.SetIncludeDocs(true)
postAllDocsOptions.SetKeys([]string{"somekey", "someotherkey"})
postAllDocsOptions.SetLimit(10)

allDocsResult, response, err := service.PostAllDocs(postAllDocsOptions)
if err != nil {
panic(err)
}

b, _ := json.MarshalIndent(allDocsResult, "", " ")
fmt.Println(string(b))

const { CloudantV1 } = require('@ibm-cloud/cloudant');

const service = CloudantV1.newInstance({});

service.postAllDocs({
db: 'orders',
includeDocs: true,
keys: ['somekey', 'someotherkey'],
limit: 10
}).then(response => {
console.log(response.result);
});

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)

All Go examples require the service object to be initialized. For more information, see the API documentation's [Authentication section](https://cloud.ibm.com/apidocs/cloudant?code=goauthentication-with-external-configuration) for examples.

The response is a JSON object that contains all documents in the database that match the parameters. The following table describes the meaning of the individual fields:



Table 2.
When running in IBM Cloud, the credentials will be read from the VCAP_SERVICES environment variable.

Create a file called my-cloudant-credentials.json in the config directory with the following content (as reference, see config/my-cloudant-credentials.json.example):

{
"password": "<password>",
"url": "<url>",
"username": "<username>"
}

Update the mappings.json file in the config directory by replacing the cloudant placeholder with the name of your DB instance:

{
"MyCloudantDB": {
"searchPatterns": [
"cloudfoundry:cloudant",
"env:kube-cloudant-credentials",
"file:config/my-cloudant-credentials.json"
]
}
}

This sample app uses the CloudEnvironment package to interact with IBM Cloud to parse environment variables. [Learn more...](https://github.com/Kitura/CloudEnvironment)

The cloudant placeholder in the cloudfoundry:cloudant configuration makes it easier to bind a user-provided Cloudant service to your app. With the cloudfoundry:cloudant configuration, you can create a Cloudant service that includes the string, cloudant somewhere in the service name and bind it to your app, without editing the config.json file. If you modify this configuration and later want to use a user-provided Cloudant service, you either need to edit the configuration to cloudfoundry:cloudant or define cloudfoundry: with the name of your user-provided service.

Find your app in the IBM Cloud [resource list](https://cloud.ibm.com/resources). On the Service Details page for your app, click Connections in the sidebar. Click the IBM Cloudant menu icon (…) and select View credentials.

Copy and paste just the credentials to the corresponding fields in your local config.json file.

Build and run your app locally.

swift build