mapr dbshell
The mapr dbshell is a tool for the creation and the lightweight manipulation of JSON tables and documents.
Before running the shell, ensure that your user ID has both the readAce
and writeAce
permissions on the volume. For information about these
permissions, see Whole Volume ACEs.
To run the shell, enter mapr dbshell
on the command line after logging
into a node in a MapR cluster.
[INFO] Unable to bind key for unsupported operation: backward-delete-word
[INFO] Unable to bind key for unsupported operation: up-history
[INFO] Unable to bind key for unsupported operation: down-history
To
suppress the messages, you can edit the /etc/inputrc
file rename the
keywords that are specified in the messages:Original name | New name |
---|---|
backward-delete-word |
backward-kill-word |
down-history |
next-history |
up-history |
previous-history |
Although you can run the command help
to see a full list of commands that
it supports, a number of important commands are described below.
Creating JSON Tables
Run the command create
, specifying the path in the MapR filesystem in
which to create the table.
create /data/movies
When you create a JSON table in the mapr dbshell
, the default column family is created automatically.
There are no commands for creating additional column families. To create any, exit the shell
and use the command maprcli
table cf create
.
Deleting JSON Documents
Run the delete
command to delete a single OJAI document. Specify the path
of the table in which the document is located and the ID of the document.
delete /data/movies --id movie0000002
Dropping JSON Tables
Run the command drop
, specifying the path to the JSON table in the MapR
filesystem.
drop /data/movies
Querying JSON Documents
Run either the find
or findbyid
command.
Examples
find /data/movies
Returns all of the documents that are in the table
/data/movies
. find /data/movies --fromid movie0000001 --toid movie0000100
Returns
all of the documents within a range of IDs that includes the specified starting ID and
excludes the specified ending ID. findbyid /data/movies --id movie0000002
Returns the document that
has the specified ID. Adding Documents to JSON Tables
insert
command. Specify the ID of the document in either of two
ways: - As the value of the
_id
field in the document - As the value of the
--id
parameter of theinsert
command
insert /data/movies --value '{"_id":"movie0000002" , "title":"Developers
on the Edge", "studio":"Command Line Studios"}'
insert /data/movies --id movie0000003 --value '{"title":"The Golden Master",
"studio":"All-Nighter"}'
Options for displaying OJAI documents
jsonoptions
to change how the content of OJAI documents is
displayed. There are two options:- pretty
- Values:
true
,false
withTags
- Values:
true
,false
Listing JSON Tables
Run the command list
, specifying a path in the MapR filesystem.
list /data