Creating Cloudant queries

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

  1. To open the Select a wizard page of the New wizard, from the main menu, select File > New > Other.
  2. To open the Create Cloudant Query wizard, expand the QMF Objects folder, select Cloudant Query, and then click Next.
  3. In the Name field, enter the name that you want to use for a query.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. On the Build tab, specify the appropriate settings and query parameters that depend on the type of the query that you create.
  9. After you build the query, to run the query and retrieve its results, click the Run Query Run query icon 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.
  10. To see the formatted read-only view of query results, switch to the Preview tab.
  11. 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.