Create a Cloudant query to retrieve data from the index that is built based on the
content of a Cloudant database.
About this task
To create a Cloudant query, complete the following steps:
Procedure
-
To open the Select a wizard page of the New wizard,
from the main menu, select .
-
To open the Create Cloudant Query wizard, expand the QMF Objects folder, select
Cloudant Query, and then click Next.
-
In the Name field, enter the name that you want to use for a
query.
-
From the Data sources field, select the Cloudant data source that
defines the connection to the database from which you want to retrieve the results.
-
From the Type field, select the type of the query that you want to
create.
- To create a query by using a secondary or search index that is defined in the Cloudant
database, select Index Query. Then go to step 6.
- To create a query with a selector, select Native Query, and then go
to step 7.
-
If you selected the Index Query option, in the Cloudant data source
tree, expand the Secondary Indexes or Search Indexes
folder, and then select the index that you want to use for the query.
-
To close the Create Cloudant Query wizard and open the query in the
editor, click Finish.
- If you create a Cloudant query based on a secondary or search index, the index that you selected
is built and opened as a metadata table on the Build tab of the
Cloudant Query editor.
- If you create a Cloudant native query, it is opened on the Build tab of
the Cloudant Native Query editor.
-
On the Build tab, specify the appropriate settings and query
parameters that depend on the type of the query that you create.
For more information, see the following topics:
-
After you build the query, to run the query and retrieve its results, click the Run
Query
toolbar button.
The query results are displayed as a grid on the
Results tab and
as a JSON tree on the
JSON tab.
Tip: Use the
Output view to see the HTTP request of the Cloudant query that you run. To
display an HTTP request in the Output view, ensure that the Show
query text check box is selected on the Output page of the
Preferences window.
-
To see the formatted read-only view of query results, switch to the
Preview tab.
-
Save the Cloudant query that you created to a repository or file.
For more information about saving objects, see the following topics:
Results
Note: To work with Cloudant query results, for example, filtering data, adding a calculated
column, creating a chart, and so on, add a Cloudant query to an analytical query and manage the
results of an analytical query. For more information about analytical queries, see the
Analytical queries and associated transformations section.