{"id":10499,"date":"2021-01-27T08:16:01","date_gmt":"2021-01-27T16:16:01","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=10499"},"modified":"2025-06-13T17:32:23","modified_gmt":"2025-06-14T00:32:23","slug":"query-couchbase-data-structures-with-n1ql-sql-for-json","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/","title":{"rendered":"Data Structures &#038; Queries with Couchbase N1QL (SQL for JSON)"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">In the <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><span style=\"font-weight: 400;\">Data Structures for NoSQL Applications<\/span><\/a> post,<span style=\"font-weight: 400;\"> we used simplified JSON data access through native collections, maps, and more. <\/span><span style=\"font-weight: 400;\">This post demonstrates querying that data using higher-level N1QL queries, the SQL-based language for JSON.<\/span><\/p>\n<div id=\"attachment_10151\" style=\"width: 778px\" class=\"wp-caption alignnone\"><a style=\"background-color: initial;\" href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-10151\" class=\"wp-image-10151 size-medium_large\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2020\/12\/couchbase_data_structures_cheatsheet-768x413.png\" alt=\"chart of couchbase data structures and examples\" width=\"768\" height=\"413\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/12\/couchbase_data_structures_cheatsheet-768x413.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/12\/couchbase_data_structures_cheatsheet-300x161.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/12\/couchbase_data_structures_cheatsheet-1024x550.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/12\/couchbase_data_structures_cheatsheet-20x11.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2020\/12\/couchbase_data_structures_cheatsheet.png 1152w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><p id=\"caption-attachment-10151\" class=\"wp-caption-text\">Summary of Couchbase Data Structure types and JSON samples.<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Developers can focus on managing basic data structures and data types using programming languages. Meanwhile, DBAs and analysts can access the same data using a query language. Couchbase does this using NoSQL data indexing methods and N1QL querying services.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Search queries with Couchbase full-text search engine are also possible and will be covered in a future post.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">What is NoSQL database indexing?\u00a0<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Indexing examines the data and determines how to find those elements again. Indexing can be applied to JSON documents, keys\/fields, or values in fields. Keys in JSON documents act like column names in tabular database indexing systems.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The database manages these collections of elements and values as indexes that point back to the source. The database backend updates indexing as documents change while storing data. Meanwhile, DBAs can optimize indexing for specific use cases such as high-volume writes or queries.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Using indexes, N1QL queries can quickly find field values that match without scanning through the original data. This method also applies to the common data structures, <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/simplifying-query-index-with-collections\/\"><span style=\"font-weight: 400;\">collections, and scopes introduced in <\/span><b>Couchbase 7.0<\/b><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Querying Couchbase data structures with N1QL<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The Couchbase web console is an easy way to view data structure documents in the database. Notice how data structure documents are often much simpler than more complex JSON documents.<\/span><\/p>\n<div id=\"attachment_10500\" style=\"width: 1392px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-10500\" class=\"size-full wp-image-10500\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-doc-preview.png\" alt=\"data structure documents listed in the bucket preview screen\" width=\"1382\" height=\"461\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview.png 1382w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview-300x100.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview-1024x342.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview-768x256.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview-20x7.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-doc-preview-1320x440.png 1320w\" sizes=\"auto, (max-width: 1382px) 100vw, 1382px\" \/><p id=\"caption-attachment-10500\" class=\"wp-caption-text\">List of data structure documents in the bucket<\/p><\/div>\n<p><span style=\"font-weight: 400;\">To start writing N1QL queries, indexing your data structure data is required. At a minimum, a bucket-wide primary index is needed for basic operations.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">CREATE PRIMARY INDEX ON `travel-sample`;<\/pre>\n<p><span style=\"font-weight: 400;\">For documents using the new collections features from <\/span><b>Couchbase 7.0<\/b><span style=\"font-weight: 400;\">, they must also be indexed.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">CREATE PRIMARY INDEX ON `travel-sample`.`scope1`.`col1`<\/pre>\n<p><strong>P<\/strong><b>rimary indexes <\/b>struggle with large datasets<span style=\"font-weight: 400;\"> but are excellent for exploring small amounts of data quickly. Use Global Secondary Indexes (GSI) when moving toward production in a big data project.<\/span><\/p>\n<h2>Listing all data documents and IDs<\/h2>\n<p><span style=\"font-weight: 400;\">However, more targeted indexing is not always possible as data structures may not have named keys. <\/span><span style=\"font-weight: 400;\">For example, a counter is just an ID and an integer value with no field name. But, if you have a map, you can create an index that targets an internal key.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A basic query for document ID can return all documents and show the field names being used.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT META().id, * FROM `travel-sample`<\/pre>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10501 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql1.png\" alt=\"query results showing data structure documents\" width=\"926\" height=\"1050\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1.png 926w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1-265x300.png 265w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1-903x1024.png 903w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1-768x871.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1-300x340.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql1-18x20.png 18w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/a><\/p>\n<p><i><span style=\"font-weight: 400;\">CurrentScore <\/span><\/i><span style=\"font-weight: 400;\">is a basic counter, whereas <\/span><i><span style=\"font-weight: 400;\">gameList <\/span><\/i><span style=\"font-weight: 400;\">is a list\/collection, etc.<\/span><\/p>\n<h3>Querying scopes\/collections for data structures<\/h3>\n<p><span style=\"font-weight: 400;\">If using scopes and collections, add them to the from clause.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT * FROM\u00a0`travel-sample`.`scope1`.`col1`<\/pre>\n<p><span style=\"font-weight: 400;\">Retrieve a specific value from a named data structure object by adding it to the where clause.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT META().id, * FROM `travel-sample` WHERE META().id = 'currentScore'<\/pre>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10502 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql2.png\" alt=\"JSON query results showing a document ID and counter value\" width=\"916\" height=\"263\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql2.png 916w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql2-300x86.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql2-768x221.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql2-20x6.png 20w\" sizes=\"auto, (max-width: 916px) 100vw, 916px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">When specifying field names (and no ID) the query returns matching values across all documents.<\/span><\/p>\n<pre class=\"lang:mysql decode:true\">SELECT name, contact FROM `travel-sample`<\/pre>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10503 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/01\/data-structure-query-results-n1ql3.png\" alt=\"JSON N1QL query showing records containing specific field names\" width=\"567\" height=\"613\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql3.png 567w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql3-277x300.png 277w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql3-300x324.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/data-structure-query-results-n1ql3-18x20.png 18w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">The query returns objects with the specific fields and their values. In the above results, only one of the data structures had the <\/span><i><span style=\"font-weight: 400;\">contact <\/span><\/i><span style=\"font-weight: 400;\">field. Two others had a <\/span><i><span style=\"font-weight: 400;\">name <\/span><\/i><span style=\"font-weight: 400;\">field, but several blank objects show there were no matching fields.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To be scalable, all query applications should also use global secondary indexes (GSI) for specific fields.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/database-indexing-best-practices\/\"><span style=\"font-weight: 400;\">Database Indexing Best Practices<\/span><\/a><span style=\"font-weight: 400;\"> article covers more computer science scenarios used in big data software engineering.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Bringing it all together<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">As you can see, querying documents and related subcomponents is very simple using Couchbase. Strategic use of sophisticated indexing methods provides even more ways to access the data your applications are creating.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Couchbase dramatically simplifies system architectures, allowing developers to get started without a lot of heavy lifting. These references will help you get started quickly.<\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><span style=\"font-weight: 400;\">Data Structures for NoSQL Applications in Couchbase 7.0<\/span><\/a><\/li>\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/scopes-and-collections-for-modern-multi-tenant-applications-couchbase-7-0\/\">Scopes and Collections for Multi-tenant Applications<\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/python-sdk\/2.5\/datastructures.html\"><span style=\"font-weight: 400;\">Couchbase data structures API<\/span><\/a><span style=\"font-weight: 400;\"> (Python SDK)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/python-sdk\/current\/howtos\/subdocument-operations.html\"><span style=\"font-weight: 400;\">Sub-document operations docs<\/span><\/a><span style=\"font-weight: 400;\"> (Python SDK)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.couchbase.com\/blog\/database-indexing-best-practices\/\"><span style=\"font-weight: 400;\">NoSQL database system index best practices<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.couchbase.com\/blog\/full-text-search-indexing-best-practices\/\"><span style=\"font-weight: 400;\">NoSQL full-text search indexing best practices<\/span><\/a><span style=\"font-weight: 400;\">\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/full-text-intro.html\"><span style=\"font-weight: 400;\">Full-text search documentation<\/span><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In the Data Structures for NoSQL Applications post, we used simplified JSON data access through native collections, maps, and more. This post demonstrates querying that data using higher-level N1QL queries, the SQL-based language for JSON. Developers can focus on managing [&hellip;]<\/p>\n","protected":false},"author":75185,"featured_media":10506,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1821,1816,1819,2453,1812,2201],"tags":[1883,1800,1696,1261],"ppma_author":[9163],"class_list":["post-10499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-architecture","category-couchbase-server","category-data-modeling","category-global-secondary-index","category-n1ql-query","category-tools-sdks","tag-data-modelling","tag-data-structures","tag-indexing","tag-json"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Structures &amp; Queries with Couchbase N1QL (SQL for JSON)<\/title>\n<meta name=\"description\" content=\"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Structures &amp; Queries with Couchbase N1QL (SQL for JSON)\" \/>\n<meta property=\"og:description\" content=\"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-27T16:16:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T00:32:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1575\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@1tylermitchell\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tyler Mitchell - Senior Product Marketing Manager\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\"},\"author\":{\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0\"},\"headline\":\"Data Structures &#038; Queries with Couchbase N1QL (SQL for JSON)\",\"datePublished\":\"2021-01-27T16:16:01+00:00\",\"dateModified\":\"2025-06-14T00:32:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\"},\"wordCount\":666,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg\",\"keywords\":[\"data modelling\",\"Data structures\",\"Indexing\",\"JSON\"],\"articleSection\":[\"Couchbase Architecture\",\"Couchbase Server\",\"Data Modeling\",\"Global Secondary Index\",\"SQL++ \/ N1QL Query\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\",\"name\":\"Data Structures & Queries with Couchbase N1QL (SQL for JSON)\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg\",\"datePublished\":\"2021-01-27T16:16:01+00:00\",\"dateModified\":\"2025-06-14T00:32:23+00:00\",\"description\":\"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg\",\"width\":1575,\"height\":628},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Structures &#038; Queries with Couchbase N1QL (SQL for JSON)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0\",\"name\":\"Tyler Mitchell - Senior Product Marketing Manager\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g\",\"caption\":\"Tyler Mitchell - Senior Product Marketing Manager\"},\"description\":\"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.\",\"sameAs\":[\"https:\/\/linkedin.com\/in\/tylermitchell\",\"https:\/\/x.com\/1tylermitchell\",\"https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Data Structures & Queries with Couchbase N1QL (SQL for JSON)","description":"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.","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:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/","og_locale":"en_US","og_type":"article","og_title":"Data Structures & Queries with Couchbase N1QL (SQL for JSON)","og_description":"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.","og_url":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-01-27T16:16:01+00:00","article_modified_time":"2025-06-14T00:32:23+00:00","og_image":[{"width":1575,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg","type":"image\/jpeg"}],"author":"Tyler Mitchell - Senior Product Marketing Manager","twitter_card":"summary_large_image","twitter_creator":"@1tylermitchell","twitter_misc":{"Written by":"Tyler Mitchell - Senior Product Marketing Manager","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/"},"author":{"name":"Tyler Mitchell - Senior Product Marketing Manager","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0"},"headline":"Data Structures &#038; Queries with Couchbase N1QL (SQL for JSON)","datePublished":"2021-01-27T16:16:01+00:00","dateModified":"2025-06-14T00:32:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/"},"wordCount":666,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg","keywords":["data modelling","Data structures","Indexing","JSON"],"articleSection":["Couchbase Architecture","Couchbase Server","Data Modeling","Global Secondary Index","SQL++ \/ N1QL Query","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/","url":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/","name":"Data Structures & Queries with Couchbase N1QL (SQL for JSON)","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg","datePublished":"2021-01-27T16:16:01+00:00","dateModified":"2025-06-14T00:32:23+00:00","description":"Access JSON NoSQL data with Couchbase data structures: maps, lists, counters, queues using N1QL\/SQL queries, indexes and efficient SDK calls.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/01\/query-indexing-blogbanner.jpg","width":1575,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Data Structures &#038; Queries with Couchbase N1QL (SQL for JSON)"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/684cc0e5c60cd2e4b591db9621494ed0","name":"Tyler Mitchell - Senior Product Marketing Manager","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/d8a7c532bf2b94b7a2fe7a8439aafd75","url":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=g","caption":"Tyler Mitchell - Senior Product Marketing Manager"},"description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind.","sameAs":["https:\/\/linkedin.com\/in\/tylermitchell","https:\/\/x.com\/1tylermitchell","https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg"],"url":"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/"}]}},"authors":[{"term_id":9163,"user_id":75185,"is_guest":0,"slug":"tylermitchell","display_name":"Tyler Mitchell - Senior Product Marketing Manager","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/876da1e4284f1832c871b3514caf7867357744b8c0a370ef6f53a79dee2f379e?s=96&d=mm&r=g","author_category":"","last_name":"Mitchell - Senior Product Marketing Manager","first_name":"Tyler","job_title":"Senior Product Marketing Manager","user_url":"","description":"Works as Senior Product Marketing Manager at Couchbase, helping bring knowledge about products into the public limelight while also supporting our field teams with valuable content. His personal passion is all things geospatial, having worked in GIS for half his career. Now AI and Vector Search is top of mind."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/10499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/75185"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=10499"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/10499\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/10506"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=10499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=10499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=10499"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=10499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}