{"id":647,"date":"2021-11-11T11:59:14","date_gmt":"2021-11-11T11:59:14","guid":{"rendered":"http:\/\/18.141.20.153\/?p=647"},"modified":"2025-08-20T11:14:55","modified_gmt":"2025-08-20T11:14:55","slug":"store-query-and-index-json-data-using-aws-documentdb","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/","title":{"rendered":"How to store, query, and index JSON data using AWS DocumentDB?"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">11<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p><img src=\"https:\/\/lh5.googleusercontent.com\/oA2Yv_zY_7B8sUXwpPalfvzV8-Ff9ypTk_zLkBRXmny3ZdjGItJ8AU88XhXqtMV3v4IsIgvKambsH1kr-NhZNSkQzF7hZsH_m1L4IOG3kzf-VRE6YyyrhvDY8a6ZcA0S69_8qF3n6bO1DZpDxeJXQQ\" style=\"width: 1600px;\"><\/p>\n\n\n\n<p class=\"has-text-align-justify\">NoSQL databases are a great choice for many modern applications such as mobile, web, and gaming that require flexible, scalable, high-performance, and highly functional databases to provide great user experiences. In this blog, we will discuss AWS DocumentDB followed by the implementation to connect to the <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-manage-backups-for-amazon-documentdb-cluster-with-mongodb-compatibility-using-aws-backup\/\">Amazon DocumentDB cluster<\/a> from the <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-set-up-a-document-database-with-amazon-documentdb-with-mongodb-compatibility-and-aws-cloud9-in-a-private-vpc\/\">AWS Cloud9<\/a> environment with a mongo shell and run a few queries.<\/p>\n\n\n\n<p>The world\u2019s largest consumer electronics maker \u201c<strong>Samsung Electronics<\/strong>\u201d VP says that :&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\">\u201d<em>With ever-increasing data volumes, and growing demand for schema flexibility, our log collection service faced challenges with managing data on a traditional relational database. Amazon DocumentDB (with MongoDB compatibility)&#8217;s support for a flexible document model and a fully managed service has relieved us from handling rigid schema and enabled us to operate mission-critical workloads at scale with ease<\/em> \u201d&nbsp;&nbsp;<\/p>\n\n\n\n<p>In this blog, we will cover:<\/p>\n\n\n\n<ul><li>SQL &amp; NoSQL Databases<\/li><li>Difference between SQL and NoSQL<\/li><li>Which database can be the right fit for your business?<\/li><li>Terminologies used in SQL vs NoSQL&nbsp;<\/li><li>Types of NoSQL databases<\/li><li>How does NoSQL work<\/li><li>NoSQL databases offered on AWS<\/li><li>What is DocumentDB?<\/li><li>Use cases of AWS DocumentDB<\/li><li>Benefits of AWS DocumentDB<\/li><li>When not to use AWS DocumentDB<\/li><li>Companies using AWS DocumentDB<\/li><li>Hands-on&nbsp;<\/li><li>Conclusion<\/li><\/ul>\n\n\n\n<h2>SQL &amp; NoSQL databases<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">SQL, short for Structured Query Language, is a programming language that is used to manage data in relational databases. Relational databases use relations (typically called tables) to store data and then match that data by using common characteristics within the dataset.<\/p>\n\n\n\n<p>Some common relational database management systems that use SQL:<\/p>\n\n\n\n<ul><li>Oracle<\/li><li>Sybase<\/li><li>Microsoft SQL Server<\/li><li>Microsoft Access<\/li><li>Ingres<\/li><\/ul>\n\n\n\n<p class=\"has-text-align-justify\">The concept of NoSQL databases became popular with Internet giants like <strong>Google<\/strong>, <strong>Facebook<\/strong>, <strong>Amazon<\/strong>, etc. who deal with huge volumes of data. The system response time becomes slow when you use RDBMS for massive volumes of data.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/uY3UHMCqe43P3vErH_frOl--uhpd0KDQOElU53P5hnzTllq5jSzm2xA7Di1CG0VgMyFTYRsrVi7uplDMRz_tzGg6YSOSF6E4QJjKCxcSAbfhuo7bQ_Ve9NjyJdZ_3HBE5uJoGheFVj9nJTD3CktT2Q\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">NoSQL databases are purpose-built for specific data models and have flexible schemas for building modern applications. NoSQL databases are widely recognized for their ease of development, functionality, and performance at scale. They are self-describing, so does not require a schema. Nor does it enforce relations between tables in all cases. All its documents are JSON documents, which are complete entities that one can readily read and understand.<\/p>\n\n\n\n<p>NoSQL database examples include:<\/p>\n\n\n\n<ul><li>MongoDB<\/li><li>MarkLogic<\/li><li>Couchbase<\/li><li>CloudDB<\/li><li>Amazon DynamoDB<\/li><li>Amazon DocumentDB<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/ajuWm8lzRxHxvd8Vsjb-t0D75lO9oYPbe7IjZD5BS_v1j2x-p33AKU5TYZVSg11UHI-7RdkVOG5apYpmla6nWhtg1NyiE_NYTulmAVGH5ylorSJweHPTqbpCvP-rkGnZ5CBjon0i4cqerXWxRtWO4w\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Difference between SQL &amp; NoSQL<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">There are many differences between SQL and NoSQL, all of which are important to understand when making a decision about what might be the best data management system for your organization, following are the differences below :<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/cboUiEBXKCRnPiUOTUIKSJoBsvmMHUmx3_22XUjZvjWMIyzqkOcRyt6w6Nt24NXJojTAcYkfFluUiOUGeUGOngxGkK4k6N8cV3h9fiMBJX_q3W6yELTEb0mKi4NI2a805d_ydVS3Rpkvs3AjCWiUEg\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Which database can be the right fit for your business?<\/h2>\n\n\n\n<p>The first and primary factor in making the SQL vs. NoSQL decision is what your data looks like.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">If your data is primarily structured, a SQL database is likely the right choice. Also, any organization will benefit from a predefined structure and set schemas, particularly if they require multi-row transactions.<\/p>\n\n\n\n<p>Situations when all data must be consistent without leaving room for error, such as with accounting systems.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">NoSQL is a good choice for those companies experiencing rapid growth with no clear schema definitions. NoSQL offers much more flexibility than a relational database and is a solid option for companies that must analyze large quantities of data or whose data structures they manage are variable.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">One of the most important decisions is whether to go with a SQL or NoSQL database as your primary database and whether you may need both to meet your needs.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">You\u2019ll need to think about what your data looks like, how you\u2019ll query your data, and the scalability you\u2019ll need in the future.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SQL databases provide great benefits for transactional data whose structure doesn\u2019t change frequently (or at all) and where data integrity is paramount. It\u2019s also best for fast analytical queries.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">NoSQL databases provide much more flexibility and scalability, which lends itself to rapid development and iteration.<\/p>\n\n\n\n<h2>Terminologies used in SQL Vs NoSQL<\/h2>\n\n\n\n<p>The following table compares the terminology used in SQL and NoSQL databases.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/mWJiczi-wvHqgP3yzgl-J7uSToPQBezoC0S2HLSA79lhhGq2FpcKNt27yvAWOEwKyRNkVGuLS4AJ6ZJ6Xx88zibZ6oAvnkODkLAsZ814C7894-houf-gGBAFf9M95T5qZOuyP5wWl79bEIgyvifvbA\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Types of NoSQL Databases<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/3vJAV6-AUddIFm32WYJALq1v79vyKkhUE_XjzNDcyk4lEU62TYJ20_8Fkw7jY93JOzU4cxD9LIV4UdNtmY7l7OVzmj3YcjDjpVHnFZWIek5rYyOEKnrg8VguSEtOQHV7Qku00lKmSZervOqiiKBUng\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p>Each type solves a problem that can\u2019t be solved with relational databases.<\/p>\n\n\n\n<p><strong>Key-Value Pair Based<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">Data is stored in key\/value pairs. Key-value pair storage databases store data as a hash table where each key is unique, and the value can be a JSON, BLOB(Binary Large Objects), string, etc.<\/p>\n\n\n\n<p>Examples of key-value stores are <strong>Redis, Voldemort, Riak, and Amazon\u2019s DynamoDB<\/strong><\/p>\n\n\n\n<p><strong>Document Oriented<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">&nbsp;A document store does assume a certain document structure that can be specified with a schema. Document stores appear the most natural among the NoSQL database types because they\u2019re designed to store everyday documents as is, and they allow for complex querying and calculations on this often already aggregated form of data<\/p>\n\n\n\n<p>Examples of document-oriented are <strong>Amazon SimpleDB, CouchDB, MongoDB, Riak, and Amazon DocumentDB.<\/strong><\/p>\n\n\n\n<p><strong>Column Based<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">Column-oriented databases work on columns and are based on BigTable paper by Google. Every column is treated separately. The values of single-column databases are stored contiguously<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Column-based NoSQL databases are widely used to manage data warehouses, business intelligence, CRM, Library card catalogs,<\/p>\n\n\n\n<p>Examples of a column-based database are <strong>HBase, Cassandra Hypertable, <\/strong>etc<\/p>\n\n\n\n<p><strong>Graph-Based<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">A graph-type database stores entities as well the relations amongst those entities. Compared to a relational database where tables are loosely connected, a Graph database is multi-relational in nature<\/p>\n\n\n\n<p>Graph base databases are mostly used for social networks, logistics, and spatial data.<\/p>\n\n\n\n<p>Examples of Graph-Based are<strong> Neo4J, Infinite Graph, OrientDB, FlockDB<\/strong><\/p>\n\n\n\n<h2>How does NoSQL work<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">NoSQL databases use a variety of data models for accessing and managing data. These types of databases are optimized specifically for applications that require large data volume, low latency, and flexible data models, which are achieved by relaxing some of the data consistency restrictions of other databases.<\/p>\n\n\n\n<p>Consider the example of modeling the schema for a simple book database:<\/p>\n\n\n\n<p class=\"has-text-align-justify\">In a relational database, a book record is often stored in separate tables, and relationships are defined by primary and foreign key constraints. In this example, the Books table has columns for ISBN, Book Title, and Edition Number, the Authors table has columns for AuthorID and Author Name, and finally, the Author-ISBN table has columns for AuthorID and ISBN.&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\">The relational model is designed to enable the database to enforce referential integrity between tables in the database, normalized to reduce redundancy, and generally optimized for storage.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">In a NoSQL database, a book record is usually stored as a JSON document. For each book, the item, ISBN, Book Title, Edition Number, Author Name, and AuthorID are stored as attributes in a single document. In this model, data is optimized for intuitive development and horizontal scalability.<\/p>\n\n\n\n<h2>NoSQL Databases Offered on AWS<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/JRz6u2YGmZbUkbXzYZO3yci5NG0ws25BGcfHoFronPRSyRZaRb5oyaxcfTJ5mJCW3e8JxOLIZdclpzN5t8a-dDdx1DJGKTEK76BAjTh96ZI4derJeg3ipBQWiXQUro5kmX3QAiTLR-3i0wYuCkqcRg\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Key-value:<\/strong> Key-value databases are highly partitionable and allow horizontal scaling at scales that other types of databases cannot achieve. Amazon <strong>DynamoDB <\/strong>is designed to provide consistent single-digit millisecond latency for any scale of workloads. This consistent performance is a big part of why the <strong>Snapchat <\/strong>Stories feature, which includes Snapchat&#8217;s largest storage write workload, moved to DynamoDB.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Document<\/strong>: Document databases make it easier for developers to store and query data in a database by using the same document model format. The flexible, semistructured, and hierarchical nature of documents and document databases allows them to evolve with applications\u2019 needs. Amazon <strong>DocumentDB <\/strong>(with MongoDB compatibility) and MongoDB are popular document databases.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Graph<\/strong>: A graph database\u2019s purpose is to make it easy to build and run applications that work with highly connected datasets. Amazon <strong>Neptune <\/strong>is a fully-managed graph database service.&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>In-memory<\/strong>: Gaming and ad-tech applications have use cases such as leaderboards, session stores, and real-time analytics that require microsecond response times.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Amazon <strong>ElastiCache <\/strong>offers <strong>Memcached <\/strong>and <strong>Redis<\/strong>, to serve low-latency, high-throughput workloads, such as <strong>McDonald\u2019s<\/strong>, that cannot be served with disk-based data stores. Amazon&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Search<\/strong>:&nbsp;Amazon <strong>Elasticsearch <\/strong>Service (Amazon ES) is purpose-built for providing near-real-time visualizations and analytics of machine-generated data by indexing, aggregating, and searching semi-structured logs and metrics.<\/p>\n\n\n\n<p>In this blog, we will focus more on one of the document-based databases AWS DocumentDB in detail<\/p>\n\n\n\n<h2>What is AWS DocumentDB?<\/h2>\n\n\n\n<p class=\"has-text-align-justify\"><a href=\"https:\/\/aws.amazon.com\/documentdb\/\" target=\"_blank\" rel=\"noreferrer noopener\">AWS DocumentDB <\/a>is a non-relational database service designed from the ground up to give you the performance, scalability, and availability you need when operating mission-critical MongoDB workloads at scale. As a document database, Amazon DocumentDB makes it easy to store, query, and index JSON data.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/eInPmQziZEcOzUfMa-W3XK1xYVRRWBqIBhOgJB7XssG-kNgBf4t_SHV7NCPkqAMzo6oEGSLgflYXS7Y249KyOSUgzHU26bjgyCxnLNrHjAUAA8Ec007efT-BVUViIZOeAHz5K6k5rg0BRJCoJWv6_A\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Use cases of AWS DocumentDB<\/h2>\n\n\n\n<h1><img src=\"https:\/\/lh6.googleusercontent.com\/ydpiQvSyoObDzFrI9weXCNtRb1czgItI9OghPU6YOIOCJ6ELLJWTyi1xwxr-2Y8d8uquCjp1lY-93KY4Jir9yn716rdMHM1bwhowOOmX2BHgwHQ06Ic0HG2q1OymDehLxaqqsu4xe9dSPFcTHIJbQA\" style=\"width: 1600px;\"><\/h1>\n\n\n\n<h2>Benefits of AWS DocumentDB<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/xvZzIKX2ib0tFKxU70PetMuUHiAtNunywz59sgbEBiQtt_0EI5sG4Wy37uXvFdjtJdvF9PS8Qpfj7-x5zpSXTuwAPMnQeH_Sy0OBAeLTdUrq9LtFXqXJve2EoJFAfqj-GU_VbgN7gzylkbPmo_P5Xg\" alt=\"Benefits of AWS DocumentDB\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\"><strong>MongoDB-compatible: <\/strong>Amazon DocumentDB implements the Apache 2.0 open source MongoDB 3.6 and 4.0 APIs by emulating the responses that a MongoDB client expects from a MongoDB server, allowing you to use your existing MongoDB drivers and tools with Amazon DocumentDB.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Fully managed: <\/strong>With Amazon DocumentDB, you don\u2019t need to worry about database management tasks, such as hardware provisioning, patching, setup, configuration, backups, or scaling. Amazon DocumentDB automatically and continuously monitors and backs up your cloud database to Amazon S3, enabling point-in-time recovery.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Performance at scale:<\/strong> Amazon DocumentDB achieves twice the throughput of currently available MongoDB managed servicesAmazon DocumentDB uses a distributed, fault-tolerant, self-healing storage system that auto-scales up to 64 TB per database cluster.<\/p>\n\n\n\n<h2>When not to use AWS DocumentDB<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/JbEP73FSGKJgTZ4JPDQceT9SuLh5Ym5JsEkxn8bN1uJ_QTl6bSdVk9AvdoVHUX6fgzARVx5Gt7ykx6e_wcfhnFYaBR2XVPGTRj2fp490gaAliYlpYIji-BMdkSMEtFiXYk_TuRIA8yiZpzoSQT_pdg\" alt=\"When not to use AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Companies using AWS DocumentDB<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/mKUWnVc5P10lx1gR7kR-b968NTzIAJ_LtNefZJazEQa7oRxFc8gYvcj_3rz6C6EKx4I7Fd5O9SE9lNb_rKRSFHDSUM2OdJB-1-Uy9n7PDxosUIcSWQ-BHBUmtQudLFu8K7R-Vgz86lbT9Y43UsJksQ\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<h2>Hands-On<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this hands-on, we will learn how to get started with Amazon DocumentDB using AWS Cloud9. We will see how to connect to Amazon DocumentDB cluster from your AWS Cloud9 environment with a Mongo shell and run a few queries.<\/p>\n\n\n\n<p>The following diagram shows the final architecture of this walkthrough.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/qTfpbsHUqPqWNi5Xz8Awh_-F6pFde1Dhtu-VVik3xtmruVz40y6NUKqONXbZN6Rc_yEvYoVtZyll2j2_lwFWzAGuOAbuAxmQKA-u5lN7dcpoDvgyPVvxnmFnKHM_D3Ps4WLh5P20JlpqiY2kxByyww\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p>Here are the steps to be followed :<\/p>\n\n\n\n<ol><li>Creating an AWS Cloud9 Environment<\/li><\/ol>\n\n\n\n<ol start=\"2\"><li>Creating a security group<\/li><\/ol>\n\n\n\n<ol start=\"3\"><li>Creating an Amazon DocumentDB cluster<\/li><\/ol>\n\n\n\n<ol start=\"4\"><li>Installing the mongo shell<\/li><\/ol>\n\n\n\n<ol start=\"5\"><li>Connect to DocumentDB cluster<\/li><\/ol>\n\n\n\n<ol start=\"6\"><li>Inserting and querying data<\/li><\/ol>\n\n\n\n<p>Firstly we start by creating a Cloud9 environment, follow the steps below<\/p>\n\n\n\n<h4><strong>1. Creating an AWS Cloud9 Environment<\/strong><\/h4>\n\n\n\n<p>1.1&nbsp; \u2013 Using the AWS management console, on the AWS Cloud9 management console, choose to Create environment.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/-zayFK4_SwIaD5hfktwNKgYIcOTYqhplD2y17FUEo7K5qSXpjktx5CUhCGqaRCXwnPBBNv_xnImozbM-2q-qXYBOm_ucR18BAfmvksWFycNXJqRXij0m3ejYixYAtAdXxQZ5xT-9rpsfH-ErdWY22A\" alt=\"\"\/><\/figure>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.2 Enter the name workfall-documentdb and click on next<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/RP1vrcwoizfjtbCTe_YuUWltpSgK-V1QtaPFEZ4G92YGLNMshqZEooY5SUDC6Q_lhTV4k_ttyZdMysjG7RV2_ymdWtgs4c5vHEPKyvuPA4SFmYYF15fCOGkuGwGDDskVJUC73aAj-ZiEwEFqzhsAlA\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;1.3 \u2013 In the Configure Settings section, accept all defaults.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;1.4 \u2013 Choose Next step.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;1.5 \u2013 In the Review section, choose Create environment.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/ZJ5oTXwYt68PIuU4FhrqVs4y7dKZE4mW9o0fMNBZGFBtnLNi3TQQPlTj7Yz3K59CvzoYG7v9Oj_drZDQQLxfz5SBRCJ8JFbDubGOBUPF6BQkXENLv0UdPiIkoXZ_sMJIPA4dol2SZgpGiLJsWrv75g\" alt=\"\"\/><\/figure>\n\n\n\n<h4>2. Creating a security group<\/h4>\n\n\n\n<p>2.1 \u2013 On the Amazon EC2 management console, under Network &amp; Security, choose Security groups.<\/p>\n\n\n\n<p>2.2 \u2013 Choose to Create a security group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/-tD7imTgEcQO-_V4n7W4vxPGTpESpQi_yA69QiMg6TMkKPHsrgMcFq65Mo8sAgzZ8JtxrSqsFnxC2tm04aT26HtB351hUCJM--mLg2Y_iAi0_AETWP1Z3lnXqAxmfe0kPhWoXh1h8fFT8YujEaS8Hw\" alt=\"\"\/><\/figure>\n\n\n\n<p>2.3 \u2013 For the Security group name, enter workfall-SG.<\/p>\n\n\n\n<p>2.4 \u2013 For Description, enter a description.<\/p>\n\n\n\n<p>2.5 \u2013 For VPC, accept the usage of your default VPC<\/p>\n\n\n\n<p>2.6 \u2013 In the Inbound rules section, choose Add rule.<\/p>\n\n\n\n<p>2.7 \u2013 For Type, choose Custom TCP Rule.<\/p>\n\n\n\n<p>2.8 \u2013 For Port Range, enter 27017.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">2.9 \u2013 The source security group is the security group for the AWS Cloud9 environment you just created. Keep the Source as the default value of Custom and enter &#8220;cloud9&#8221; in the field adjacent to Custom to see a list of available security groups.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/rUlgTWvRY_zba8aGVgVU0TwczcjV3b_7aVauXLI28LmGe-gGX0QUTStBGAJbN99ZTIbAypDewCdSPRaeuDL6j96KKtpS1b4BJUI-0FILsdeKyx9TwNO3erKUPDKeVgg5nn7P26PjIpoHGrXcz1EfEA\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p>&nbsp;2.10 Choose the security group with the name aws-cloud9-<em>&lt;environment name&gt;<\/em><\/p>\n\n\n\n<p>2.11 \u2013 Accept all other defaults and choose to Create security group. You do not need to modify the outbound rules.<\/p>\n\n\n\n<h4>3.&nbsp; Creating an Amazon DocumentDB cluster<\/h4>\n\n\n\n<p>3.1 \u2013 On the Amazon DocumentDB management console, under Clusters, choose to Create.<\/p>\n\n\n\n<p><img loading=\"lazy\" width=\"624\" height=\"187\" src=\"https:\/\/lh4.googleusercontent.com\/MBzwOP2gmNWs2owS1l1a6oDjeDsyIFl-t1iuwfENRo4cHp0xp4Wu2MWo_lbldgwHjRqBbXW-Sqr0TuftLv5IZ-oYdGbG-6cN_p4Ed88qvhaVj9FjEjCQFtetxp5Iv_Fv43EjirEa_nqeyKfbUuiqzA\"><\/p>\n\n\n\n<p class=\"has-text-align-justify\">3.2 \u2013 On the Create AmazonDocumentDB cluster page, select db.t3.medium under Instance class, and then choose 1 for Number of instances. These options will help minimize costs.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/QLZvE6HATdLiyJHE95CKBJ2mQq2eocWHnxHbDXAfJy3c7dKGMLChJ5JUsT5yQvI5S3J_B5jwqS7E2Fi6T_u5I2zt6QWJtA4ZOqU9JhetzEFXUefg6oX87p2CqSrg5_VJIHcQGJ6Qo2gK5FPUkA8C8Q\" alt=\"\"\/><\/figure>\n\n\n\n<p>3.3 \u2013 Leave other settings at their default.<\/p>\n\n\n\n<p>3.4 \u2013 In the Authentication section, enter a username and password<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/ij-PGjlacTRnzM88d5EITsSHFzlfcjAC7Zl40RQ1hYWoZXKQTOmxjt3pMNoGmbUhB8KAdn105wd_D5ziKCnQW74mZZPjk-06-7dZEtbJx_VTIcE5lJy0yWheBXiJ2jeiqq5kdNJ5zpUr9ZJLd4xW5g\" alt=\"AWS DocumentDB\"\/><\/figure>\n\n\n\n<p>3.5 Turn on advance setting<\/p>\n\n\n\n<p>3.6 \u2013 In the Network settings section, for VPC security groups, choose workfall-SG,choose Create Cluster<\/p>\n\n\n\n<h4><strong>4. Installing the mongo shell<\/strong><\/h4>\n\n\n\n<p>4.1 \u2013 If your AWS Cloud9 environment is still open, you can skip to step 3.<\/p>\n\n\n\n<p>4.2 \u2013 On the AWS Cloud9 management console, under Your environments, choose the name created earlier.<\/p>\n\n\n\n<p>4.3 \u2013 Choose open IDE.<\/p>\n\n\n\n<p>4.4 \u2013 At the command prompt, create the repository file with the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho -e &quot;&#91;mongodb-org-3.6] \\nname=MongoDB Repository\\nbaseurl=https:\/\/repo.mongodb.org\/yum\/amazon\/2013.03\/mongodb-org\/3.6\/x86_64\/\\ngpgcheck=1 \\nenabled=1 \\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-3.6.asc&quot; | sudo tee \/etc\/yum.repos.d\/mongodb-org-3.6.repo\n<\/pre><\/div>\n\n\n<p>4.5 \u2013 When it is complete, install the mongo shell with the following code:<\/p>\n\n\n\n<p><code>sudo yum install -y mongodb-org-shell<\/code><\/p>\n\n\n\n<p>4.6 \u2013 To encrypt data in transit, download the CA certificate for Amazon DocumentDB. See the following code:<\/p>\n\n\n\n<p><code>wget https:\/\/s3.amazonaws.com\/rds-downloads\/rds-combined-ca-bundle.pem<\/code><\/p>\n\n\n\n<p>4.7 \u2013 You are now ready to connect to your Amazon DocumentDB cluster.<\/p>\n\n\n\n<h4>5. Connect to DocumentDB Cluster<\/h4>\n\n\n\n<p>5.1 \u2013 On the Amazon DocumentDB management console, under Clusters, locate your cluster.&nbsp;<\/p>\n\n\n\n<p>5.2 \u2013 Choose the cluster you created by clicking on the cluster identifier&nbsp;<\/p>\n\n\n\n<p>5.3 \u2013 Copy the connection string provided under \u201cConnect to this cluster with the mongo shell\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/IsVrc2BoUXAhOssA0o_jF6XKaSVUXVy7aHetNrs_-SlPYeaDYYsZDaWXYIbOzgoy99h3weJN4RFcwDSpg_WaCKRNXPFnV0R92WaWpuLhffgIFx-LohGAVH1JcIiRMDQ1hyk2sJTIDhzAENEULoNatw\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Omit &lt;insertYourPassword&gt; so that you are prompted for the password by the mongo shell when you connect. This way, you don\u2019t have to type your password in cleartext.<\/p>\n\n\n\n<p>5.4 \u2013 Your connection string should look like the following code (see screenshot)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/T18ymsLS8mO79YP0h9ZAUDByu9bJMRhA9ToVGN0EISjjaHPbDZF7oJPMtYjPyfOC0rRtPBqGoyinp2UBaOJ0_BY8CxUPKo7PBYbM25TCRhiNDpq8M0MLBym-_XiZh89AAYRbH2VJr5wV5lI-PQKmsg\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">5.5 \u2013 When you enter your password and can see the rs0:PRIMARY&gt; prompt, you are successfully connected to your Amazon DocumentDB cluster<\/p>\n\n\n\n<h4>6. Inserting and querying data<\/h4>\n\n\n\n<p class=\"has-text-align-justify\">6.1 &#8211; Now that you are connected to your cluster, you can run a few queries to get familiar with using a document database.<\/p>\n\n\n\n<p>To <strong>insert <\/strong>a single document, enter the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.collection.insert({&quot;hi&quot;:&quot;hello&quot;})\n<\/pre><\/div>\n\n\n<p>You get the following output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nWriteResult({ &quot;nInserted&quot; : 1 })\n<\/pre><\/div>\n\n\n<p class=\"has-text-align-justify\">6.2 &#8211; You can read the document that you wrote with the findOne() command (because it only returns a single document). See the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.collection.findOne()\n\nYou get the following output:\n\n{ &quot;_id&quot; : ObjectId(&quot;5e401fe56056fda7321fbd67&quot;), &quot;hi&quot; : &quot;hello&quot; }\n<\/pre><\/div>\n\n\n<p class=\"has-text-align-justify\">6.3 &#8211; To perform a few more queries, consider the gaming profiles use case. First, insert a few entries into a collection entitled profiles. See the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.profiles.insertMany(&#91;\n\n{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;john&quot;, &quot;status&quot;: &quot;active&quot;, &quot;level&quot;: 1, &quot;score&quot;:10},\n\n{ &quot;_id&quot; : 2, &quot;name&quot; : &quot;rob&quot;, &quot;status&quot;: &quot;inactive&quot;, &quot;level&quot;: 2, &quot;score&quot;:50},])\n\nYou get the following output:\n\n{ &quot;acknowledged&quot; : true, &quot;insertedIds&quot; : &#91; 1, 2] }\n<\/pre><\/div>\n\n\n<p>6.4 &#8211; Use the find() command to return all the documents in the profiles collection. See the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.profiles.find()\n\nYou get the following output:\n\n{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;john&quot;, &quot;status&quot;: &quot;active&quot;, &quot;level&quot;: 1, &quot;score&quot;:10}\n\n{ &quot;_id&quot; : 2, &quot;name&quot; : &quot;rob&quot;, &quot;status&quot;: &quot;inactive&quot;, &quot;level&quot;: 2, &quot;score&quot;:50}\n<\/pre><\/div>\n\n\n<p>6.5 &#8211; Use a query for a single document using a filter. See the following code.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.profiles.find({name: &quot;john&quot;})\n\nYou get the following output:\n\n{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;john&quot;, &quot;status&quot;: &quot;active&quot;, &quot;level&quot;: 1, &quot;score&quot;:10}\n<\/pre><\/div>\n\n\n<p class=\"has-text-align-justify\">6.6 &#8211; A common use case in gaming is finding a profile for a given user and increment a value in the user\u2019s profile. So we increase their score by +10.<\/p>\n\n\n\n<p>To do that, use the findAndModify command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.profiles.findAndModify({\n\n   query: { name: &quot;john&quot;, status: &quot;active&quot;},\n\n   update: { $inc: { score: 10 } }})\n<\/pre><\/div>\n\n\n<p>You get the following output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n{\n      &quot;_id&quot; : 1,\n      &quot;name&quot; : &quot;john&quot;,\n      &quot;status&quot; : &quot;active&quot;,\n      &quot;level&quot; : 1,\n      &quot;score&quot; : 20\n}\n<\/pre><\/div>\n\n\n<p>6.7 &#8211; You can verify the result with the following query:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.profiles.find({name: &quot;john&quot;})\n\nYou get the following output:\n\n{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;john&quot;, &quot;status&quot; : &quot;active&quot;, &quot;level&quot; : 1, &quot;score&quot; : 20 }\n<\/pre><\/div>\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, We had a look at traditional RDBMS and how NoSQL databases are becoming the ideal choice for enterprises. We have also explored which options and parameters should be considered while making the right choice for the business use case in selecting the type of database. We also had a look at different types of NoSQL databases and also had a deep dive into DocumentDB, its benefits, and how to start working with DocumentDB. We will discuss other NoSQL databases offered by AWS in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on AWS and relevant technologies.&nbsp;<\/p>\n\n\n\n<p>For any further queries, feel free to post your comments, we are happy to help!<\/p>\n\n\n\n<p>Meanwhile \u2026<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you\u2019re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at<a href=\"https:\/\/www.workfall.com\/partner\/\"> workfall.com\/partner<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">11<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> NoSQL databases are a great choice for many modern applications such as mobile, web, and gaming that require flexible, scalable, high-performance, and highly functional databases to provide great user experiences. In this blog, we will discuss AWS DocumentDB followed by the implementation to connect to the Amazon DocumentDB cluster from the AWS Cloud9 environment with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":648,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[2],"tags":[3,220,4,221,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-11T11:59:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-20T11:14:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png\",\"width\":1200,\"height\":628,\"caption\":\"AWS DocumentDB and JSON Data - Workfall\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/\",\"name\":\"How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage\"},\"datePublished\":\"2021-11-11T11:59:14+00:00\",\"dateModified\":\"2025-08-20T11:14:55+00:00\",\"description\":\"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to store, query, and index JSON data using AWS DocumentDB?\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"How to store, query, and index JSON data using AWS DocumentDB?\",\"datePublished\":\"2021-11-11T11:59:14+00:00\",\"dateModified\":\"2025-08-20T11:14:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage\"},\"wordCount\":2454,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png\",\"keywords\":[\"AWS\",\"AWS DocumentDB\",\"Cloud\",\"NoSQL\",\"workfall\"],\"articleSection\":[\"AWS Cloud Computing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog","description":"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/","og_locale":"en_US","og_type":"article","og_title":"How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog","og_description":"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2021-11-11T11:59:14+00:00","article_modified_time":"2025-08-20T11:14:55+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png","width":1200,"height":628,"caption":"AWS DocumentDB and JSON Data - Workfall"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/","name":"How to store, query, and index JSON data using AWS DocumentDB? - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage"},"datePublished":"2021-11-11T11:59:14+00:00","dateModified":"2025-08-20T11:14:55+00:00","description":"AWS DocumentDB is a non-relational database service you need when operating mission-critical MongoDB workloads at scale.","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"How to store, query, and index JSON data using AWS DocumentDB?"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"How to store, query, and index JSON data using AWS DocumentDB?","datePublished":"2021-11-11T11:59:14+00:00","dateModified":"2025-08-20T11:14:55+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#webpage"},"wordCount":2454,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/store-query-and-index-json-data-using-aws-documentdb\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png","keywords":["AWS","AWS DocumentDB","Cloud","NoSQL","workfall"],"articleSection":["AWS Cloud Computing"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DocumentDB01.png","jetpack-related-posts":[{"id":221,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-migrate-rds-mysql-database-to-rds-postgresql-database-using-aws-database-migration-servicedms\/","url_meta":{"origin":647,"position":0},"title":"How to migrate RDS MySQL database to RDS PostgreSQL database using AWS Database Migration Service(DMS)?","date":"October 27, 2021","format":false,"excerpt":"Do you want to migrate data from one type of DB engine (MySQL) to another type of DB engine(PostgreSQL) with little or no downtime? In today's fast-paced environment, application, and database availability must be considered 24 hours a day, seven days a week. Some of your applications may be unable\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS Database Migration Service","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/DMS.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":614,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-do-database-migration-using-aws-database-migration-service-dms-from-on-premise-ec2-to-rds\/","url_meta":{"origin":647,"position":1},"title":"AWS DMS: Migrating On-Premise\/EC2 Databases to RDS Made Simple","date":"November 11, 2021","format":false,"excerpt":"Do you want to migrate your on-premise databases to AWS with minimal or no downtime? In today\u2019s fast-paced world,\u00a024\/7 application and database availability are the basic criteria to consider. In this case, some of your applications may not be able to afford significant downtime while migrating on-premises databases. In this\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Database Migration using AWS Database Migration Service (DMS)","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/DMS.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":542,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-on-demand-backups-and-restore-the-backup-for-amazon-rds-using-aws-backuppart-1\/","url_meta":{"origin":647,"position":2},"title":"How to create on-demand backups and restore the backup for Amazon RDS using AWS Backup(Part 1)?","date":"November 10, 2021","format":false,"excerpt":"When we are using various data services like RDS, EBS, EFS, and DynamoDB to store data in the AWS Cloud, we also have to use some kind of backup solution to meet the data retention requirements. We need a centralized and effective solution for scheduling events like CloudWatch events, cleaning\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS Backup","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/backup1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":541,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-build-a-serverless-event-driven-workflow-with-aws-glue-and-amazon-eventbridgepart-1\/","url_meta":{"origin":647,"position":3},"title":"How to build a serverless event-driven workflow with AWS Glue and Amazon EventBridge(Part 1)?","date":"November 10, 2021","format":false,"excerpt":"Have you ever wondered how huge IT companies construct their ETL pipelines for production? Are you curious about how TBs and ZBs of data are effortlessly captured and rapidly processed to a database or other storage for data scientists and analysts to use? The answer is the serverless data integration\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS Glue","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/Glue.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":523,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-an-api-endpoint-to-provision-a-dynamodb-table-using-aws-appsync-part-1\/","url_meta":{"origin":647,"position":4},"title":"How to create an API endpoint to provision a DynamoDB table using AWS AppSync? (Part 1)","date":"November 10, 2021","format":false,"excerpt":"AppSync is an AWS-managed GraphQL layer that is built on the benefits of GraphQL and adds a few more cool features to its web and mobile SDKs. AppSync is the best of GraphQL with less complexity than before, which works out great for Serverless applications. You can refer to our\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS AppSync - Integration with React Application","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-1-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":675,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-set-up-a-continuous-deployment-pipeline-to-deploy-versions-of-an-application-on-aws-elastic-beanstalk-using-aws-codepipeline-part-1\/","url_meta":{"origin":647,"position":5},"title":"How to set up a continuous deployment pipeline to deploy versions of an application on AWS Elastic Beanstalk using AWS CodePipeline (Part 1)?","date":"November 24, 2021","format":false,"excerpt":"Do you have concerns about managing and deploying web applications? With AWS Elastic Beanstalk, you can launch your full web application in just a few minutes by simply uploading the code. Starting with capacity provisioning, load balancing, auto-scaling, and application health monitoring, this service will take care of the whole\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS Elastic Beanstalk - Workfall","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-6.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/647"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=647"}],"version-history":[{"count":6,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/647\/revisions"}],"predecessor-version":[{"id":1804,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/647\/revisions\/1804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/648"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}