Querying with HPE Ezmeral Data Fabric Database Shell

This section describes how to query JSON documents using either the find or findbyid command in HPE Ezmeral Data Fabric Database Shell (dbshell). It introduces the functionality the find command supports and describes the two ways to specify your queries. It also provides links to reference pages and examples.

The findbyid command allows you to retrieve a single document with a specified id from a HPE Ezmeral Data Fabric Database JSON table.

The find command allows you to specify projections and filter conditions (using JSON strings) to retrieve specific documents. It also allows you to specify the following options:

  • Range of document IDs to retrieve
  • Offset from which to start retrieval
  • Order by to sort fields in the document
  • Limit on the number of documents to retrieve
To invoke HPE Ezmeral Data Fabric Database shell, run the following command on a MapR cluster node:
% mapr dbshell

For a complete list and description of options available, see dbshell find or findbyid.

Alternatives for Writing Dbshell Query Commands

You can construct your dbshell queries in one of two ways:

  • Use individual options in the find command
  • Use the --query option in the find command and specify keywords as arguments to --query

The following example illustrates the differences between the two alternatives.

Suppose you want to query the table /apps/tab with the following criteria:

  • Select fields f1 and f2
  • Limit the result to ten documents
  • Skip the first two documents
  • Filter documents where the field f3 equals 15
  • Sorts on field f1

Click on each of the following tabs to see the syntax for each alternative:

find /apps/tab --fields f1,f2 --limit 10 --offset 2 --where {"$eq":{"f3":15}} --orderby f1
find /apps/tab --query {"$select":["f1","f2"],"$limit":10,"$offset":2,"$where":{"$eq":{"f3":15}},"$orderby":"f1"}

For more examples on how to use the two query alternatives, see the following links:

Use Individual Options in find Use the --query Option in find
Query Examples with Other Options
NOTE With both options, you need to specify the query condition using OJAI Query Condition Syntax.