Query: Fundamentals
The Query Service supports the querying of data by means of the SQL++ query language.
As its primary function, the Query service enables you to issue queries to extract data from Couchbase server. You can also issue queries for data definition (defining indexes) and data manipulation (adding or deleting data). The Query Service depends on both the Index Service and the Data Service.
To issue queries, you can use a Couchbase SDK, the REST API, or the tools provided by the Query service: the cbq shell or the Query workbench.
When to Use Queries
Use the Query service for operational queries — for example, the front-end queries behind every page display or navigation.
Use the Analytics service when you don’t know every aspect of the query in advance — for example, if the data access patterns change frequently, or you want to avoid creating an index for each data access pattern, or you want to run ad hoc queries for data exploration or visualization.
Use the Full Text Search service when you want to take advantage of natural-language querying.
SQL++ for Query
Couchbase Server can be queried using SQL++, the Couchbase Server query language. The Couchbase implementation of SQL++ was formerly known as N1QL (pronounced "nickel"), which derives its name from the non-first normal form of the data model.
SQL++ is an expressive, powerful, and complete SQL dialect for querying, transforming, and manipulating JSON data. Based on SQL, it’s immediately familiar to developers who can quickly start developing rich applications.