A newer version of this documentation is available.

View Latest

Selection Queries

    March 23, 2025
    + 12

    This guide explains how to read data with a N1QL query. The N1QL query language enables you to retrieve a document by inspecting its contents to see if it matches a certain criterion. Key-value operations are quicker, but querying documents allows for richer search capabilities — for example, "Give me all likes and followed users located in the US", versus "Give me a user with the ID e3d882a4".

    Selecting Data with Queries

    To read data from a data source using N1QL, you must use a selection query; that is, a query using the SELECT statement.

    Querying Across Relationships

    You can use a join to read objects from one data source, combine them with corresponding objects from another data source, and return the joined objects.

    Nesting and Unnesting Documents

    N1QL provides syntax which enables you to nest (create) or unnest (flatten) arrays of embedded documents in a query.

    Grouping and Aggregation

    You can use aggregate functions to perform calculations over multiple values. Grouping enables you to display the results in groups.