{"id":1828,"date":"2021-01-27T08:16:01","date_gmt":"2021-01-27T16:16:01","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/"},"modified":"2021-01-27T08:16:01","modified_gmt":"2021-01-27T16:16:01","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":"\n<p><span>In the <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><span>Data Structures for NoSQL Applications<\/span><\/a> post,<span> we used simplified JSON data access through native collections, maps, and more. <\/span><span>This post demonstrates querying that data using higher-level N1QL queries, the SQL-based language for JSON.<\/span><\/p>\n\n\n\n<figure id=\"attachment_10151\" aria-describedby=\"caption-attachment-10151\" style=\"width: 768px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10151 size-medium_large\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase_data_structures_cheatsheet-768x413-1.png\" alt=\"chart of couchbase data structures and examples\" width=\"768\" height=\"413\"><\/a><figcaption id=\"caption-attachment-10151\" class=\"wp-caption-text\">Summary of Couchbase Data Structure types and JSON samples.<\/figcaption><\/figure>\n\n\n\n<p><span>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\n\n\n<p><span>Search queries with Couchbase full-text search engine are also possible and will be covered in a future post.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span>What is NoSQL database indexing?\u00a0<\/span><\/h2>\n\n\n\n<p><span>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\n\n\n<p><span>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\n\n\n<p><span>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>collections, and scopes introduced in <\/span><b>Couchbase 7.0<\/b><\/a><span>.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span>Querying Couchbase data structures with N1QL<\/span><\/h2>\n\n\n\n<p><span>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\n\n\n<figure id=\"attachment_10500\" aria-describedby=\"caption-attachment-10500\" style=\"width: 1382px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10500\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-doc-preview.png\" alt=\"data structure documents listed in the bucket preview screen\" width=\"1382\" height=\"461\"><figcaption id=\"caption-attachment-10500\" class=\"wp-caption-text\">List of data structure documents in the bucket<\/figcaption><\/figure>\n\n\n\n<p><span>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\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]CREATE PRIMARY INDEX ON `travel-sample`;[\/crayon]<\/p>\n\n\n\n<p><span>For documents using the new collections features from <\/span><b>Couchbase 7.0<\/b><span>, they must also be indexed.<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]CREATE PRIMARY INDEX ON `travel-sample`.`scope1`.`col1`[\/crayon]<\/p>\n\n\n\n<p><strong>P<\/strong><b>rimary indexes <\/b>struggle with large datasets<span> 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\n\n\n<h2 class=\"wp-block-heading\">Listing all data documents and IDs<\/h2>\n\n\n\n<p><span>However, more targeted indexing is not always possible as data structures may not have named keys. <\/span><span>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\n\n\n<p><span>A basic query for document ID can return all documents and show the field names being used.<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]SELECT META().id, * FROM `travel-sample`[\/crayon]<\/p>\n\n\n\n<p><a href=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10501 size-full\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql1.png\" alt=\"query results showing data structure documents\" width=\"926\" height=\"1050\"><\/a><\/p>\n\n\n\n<p><i><span>CurrentScore <\/span><\/i><span>is a basic counter, whereas <\/span><i><span>gameList <\/span><\/i><span>is a list\/collection, etc.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Querying scopes\/collections for data structures<\/h3>\n\n\n\n<p><span>If using scopes and collections, add them to the from clause.<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]SELECT * FROM\u00a0`travel-sample`.`scope1`.`col1`[\/crayon]<\/p>\n\n\n\n<p><span>Retrieve a specific value from a named data structure object by adding it to the where clause.<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]SELECT META().id, * FROM `travel-sample` WHERE META().id = &#8216;currentScore'[\/crayon]<\/p>\n\n\n\n<p><a href=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10502 size-full\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql2.png\" alt=\"JSON query results showing a document ID and counter value\" width=\"916\" height=\"263\"><\/a><\/p>\n\n\n\n<p><span>When specifying field names (and no ID) the query returns matching values across all documents.<\/span><\/p>\n\n\n<p>[crayon lang=&#8221;mysql&#8221; decode=&#8221;true&#8221;]SELECT name, contact FROM `travel-sample`[\/crayon]<\/p>\n\n\n\n<p><a href=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10503 size-full\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/data-structure-query-results-n1ql3.png\" alt=\"JSON N1QL query showing records containing specific field names\" width=\"567\" height=\"613\"><\/a><\/p>\n\n\n\n<p><span>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>contact <\/span><\/i><span>field. Two others had a <\/span><i><span>name <\/span><\/i><span>field, but several blank objects show there were no matching fields.<\/span><\/p>\n\n\n\n<p><span>To be scalable, all query applications should also use global secondary indexes (GSI) for specific fields.<\/span><\/p>\n\n\n\n<p><span>This <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/database-indexing-best-practices\/\"><span>Database Indexing Best Practices<\/span><\/a><span> article covers more computer science scenarios used in big data software engineering.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span>Bringing it all together<\/span><\/h2>\n\n\n\n<p><span>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\n\n\n<p><span>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\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/data-structures-for-nosql-applications-in-couchbase-7-0\/\"><span>Data Structures for NoSQL Applications in Couchbase 7.0<\/span><\/a><\/li>\n\n\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\n\n<li><a href=\"https:\/\/docs.couchbase.com\/python-sdk\/2.5\/datastructures.html\"><span>Couchbase data structures API<\/span><\/a><span> (Python SDK)<\/span><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/python-sdk\/current\/howtos\/subdocument-operations.html\"><span>Sub-document operations docs<\/span><\/a><span> (Python SDK)<\/span><\/li>\n\n\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/database-indexing-best-practices\/\"><span>NoSQL database system index best practices<\/span><\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.couchbase.com\/blog\/full-text-search-indexing-best-practices\/\"><span>NoSQL full-text search indexing best practices<\/span><\/a><span>\u00a0<\/span><\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/fts\/full-text-intro.html\"><span>Full-text search documentation<\/span><\/a><\/li>\n\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 basic data structures and data types using programming languages. Meanwhile, DBAs and analysts can access [&hellip;]<\/p>\n","protected":false},"author":75185,"featured_media":1827,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[179,54,189,411,18,64],"tags":[249,454,192,30],"ppma_author":[326],"class_list":["post-1828","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"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\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=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/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\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/query-couchbase-data-structures-with-n1ql-sql-for-json\\\/\"},\"wordCount\":738,\"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\\\/5\\\/2026\\\/05\\\/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\\\/5\\\/2026\\\/05\\\/query-indexing-blogbanner.jpg\",\"datePublished\":\"2021-01-27T16:16:01+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\\\/5\\\/2026\\\/05\\\/query-indexing-blogbanner.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/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\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"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:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=gd8a7c532bf2b94b7a2fe7a8439aafd75\",\"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.\",\"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","og_image":[{"width":1575,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/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","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/query-couchbase-data-structures-with-n1ql-sql-for-json\/"},"wordCount":738,"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\/5\/2026\/05\/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\/5\/2026\/05\/query-indexing-blogbanner.jpg","datePublished":"2021-01-27T16:16:01+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\/5\/2026\/05\/query-indexing-blogbanner.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/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\/sites\/5\/2026\/06\/logo.svg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","width":"1024","height":"1024","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:\/\/secure.gravatar.com\/avatar\/ebec3213e756f2e1f7118fcb5722e2cd1484c9256ae34ceb8f77054b986f21ce?s=96&d=mm&r=gd8a7c532bf2b94b7a2fe7a8439aafd75","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.","sameAs":["https:\/\/linkedin.com\/in\/tylermitchell","https:\/\/x.com\/1tylermitchell","https:\/\/www.youtube.com\/channel\/UCBZFuoiTcg0f3lGSQwLjeTg"],"url":"https:\/\/www.couchbase.com\/blog\/author\/tylermitchell\/"}]}},"acf":[],"authors":[{"term_id":326,"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","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1828","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=1828"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1828\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/1827"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=1828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=1828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=1828"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}