Querying with HPE Data Fabric Database Shell
This section describes how to query JSON documents using either the
find or findbyid command in HPE 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 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
% mapr dbshellFor 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
findcommand - Use the
--queryoption in thefindcommand 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
f1andf2 - Limit the result to ten documents
- Skip the first two documents
- Filter documents where the field
f3equals 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 |