1. Home
  2. /
  3. N1ql
  4. /
  5. Redis Sorted Sets

Redis Sorted Sets - N1ql Typing CST Test

Loading…

Redis Sorted Sets — N1ql Code

Working with sorted sets in Redis.

# Add scores
ZADD leaderboard 100 "Alice"
ZADD leaderboard 200 "Bob"

# Get top players
ZREVRANGE leaderboard 0 -1 WITHSCORES

N1ql Language Guide

N1QL (Non-First Normal Form Query Language) is Couchbase’s SQL-like query language designed for JSON document databases. It enables SQL-style querying, joins, aggregation, indexing, and full-text search on flexible JSON data.

Primary Use Cases

  • ▸SQL-style querying on JSON data
  • ▸JOIN operations on NoSQL JSON documents
  • ▸High-performance analytics
  • ▸Full-text search and indexing
  • ▸Caching and session management
  • ▸Recommendation engines and personalization pipelines

Notable Features

  • ▸Full SQL capabilities (SELECT, JOIN, GROUP BY, ORDER BY)
  • ▸Powerful secondary indexing
  • ▸Supports JSON-based schema flexibility
  • ▸User-defined functions and expressions
  • ▸Full-text search integration (FTS)
  • ▸High-performance distributed execution

Origin & Creator

Developed by Couchbase Inc., introduced publicly in 2015 to provide SQL querying capabilities on JSON in a distributed NoSQL database.

Industrial Note

N1QL excels in environments needing massive read/write throughput with SQL-like querying over JSON-such as ad-tech, gaming, finance, e-commerce personalization, digital catalogs, session stores, caching layers, and multi-model microservices.

More N1ql Typing Exercises

Basic N1QL QueriesBasic SQL JoinsMongoDB AggregationPostgreSQL Window FunctionsCassandra Batch InsertNeo4j Path QuerySQLite IndexingElasticsearch Full-Text SearchInfluxDB Aggregation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlCypherGremlin