Running MapR Database Shell Commands in Zeppelin
This section contains a sample of MapR Database shell commands that you can run in your Apache Zeppelin notebook.
About this task
Procedure
-
Invoke the MapR Database shell:
%maprdb.shell
-
Create a MapR Database JSON table in your home
directory on the MapR File System:
create ./sample_table
-
Insert some documents in to the table:
insert ./sample_table --value '{"_id": "FYWN1w","name":"Dental by Design","city":"Ahwatukee","stars":4.0}' insert ./sample_table --value '{"_id": "He-G7v","name":"Stephen Szabo Salon","city":"McMurray","stars":3.0}' insert ./sample_table --value '{"_id": "KQPW8l","name":"Western Motor Vehicle","city":"Phoenix","stars":1.5}' insert ./sample_table --value '{"_id": "8DShNS","name":"Sports Authority","city":"Tempe","stars":3.0}' insert ./sample_table --value '{"_id": "PfOCPj","name":"Brick House Tavern + Tap","city":"Cuyahoga Falls","stars":3.5}' insert ./sample_table --value '{"_id": "o9eMRC","name":"Messina","city":"Stuttgart","stars":4.0}' insert ./sample_table --value '{"_id": "kCoE3j","name":"BDJ Realty","city":"Las Vegas","stars":4.0}' insert ./sample_table --value '{"_id": "OD2hnu","name":"Soccer Zone","city":"Las Vegas","stars":1.5}' insert ./sample_table --value '{"_id": "EsMcGi","name":"Any Given Sundae","city":"Wexford","stars":5.0}' insert ./sample_table --value '{"_id": "TGWhGN","name":"Detailing Gone Mobile","city":"Henderson","stars":5.0}'
-
Retrieve the documents with at least a 4 star rating:
find ./sample_table --where '{"$ge":{"stars":4}}'
The query returns the following:{"_id": "EsMcGi","name":"Any Given Sundae","city":"Wexford","stars":5.0} {"_id": "FYWN1w","name":"Dental by Design","city":"Ahwatukee","stars":4.0} {"_id": "TGWhGN","name":"Detailing Gone Mobile","city":"Henderson","stars":5.0} {"_id": "kCoE3j","name":"BDJ Realty","city":"Las Vegas","stars":4.0} {"_id": "o9eMRC","name":"Messina","city":"Stuttgart","stars":4.0} 5 document(s) found.