Querying Data and Query Data Service

The data service provides a key-value API that returns a document based on a given key. The API returns the full document with low latency. This method is restrictive as you can use this method only if you have the document keys in your hand. However, it is the fastest way to retrieve data. For more information on retrieving documents with document keys, see
Data Service and Core Data Access. This retrieval method is available through the data service.

Querying data using View queries

Views provide an API to query any existing map-reduce view. Views take in a user defined map and reduce function to process a JSON document and emit document attributes as the view keys. View queries can query on the view keys to retrieve the values defined by the map and reduce functions or the document keys. Views are typically useful for interactive reporting type queries where complex data processing and custom data reshaping is necessary. This query method is available through the data service. For more information, see
Querying Data with Views.

Querying data using Spatial queries

Spatial Views provide an API to query any existing spatial view. Spatial Views take in a user defined map function to process geographic information in JSON document and emit geographic coordinates as the view keys. Spatial View queries can query the geographic information using multidimensional bounding boxes that can retrieve the documents that have coordinates and are contained in the bounding box. Spatial Views are typically useful for location aware applications with geographic queries. This query method is available through the data service. For more information, see
Querying Geographic Data with Spatial Views.

Querying data using N1QL queries

N1QL provides a SQL like query language and is an expressive way to query data in JSON document. Unlike views, N1QL does not require a dedicated index and can issue ad-hoc queries on data. N1QL can also define indexes that can engage the GSI indexer or the View indexer. Indexes provide fast lookup for N1QL queries. N1QL queries are best for interactive applications that need low latency response times. This method is available through the query service. For more information, see
Querying Data with N1QL.

Querying Data with Views View query requests come in through port 8092 to one of the nodes running the data service. The communication happens over the REST API exposed by the view query engine.

Querying Geographic Data with Spatial Views Spatial views operate in a similar way as incremental MapReduce views. The request handling, load balancing, and partitioning works the same way as views, and the same staleness parameters are supported as views.

Querying Data with N1QL The N1QL query requests come in through port 8093 to one of the nodes running the query service. The communication happens over the REST API exposed by the N1QL query engine. Subsequent requests are load balanced across all nodes running the query service to execute N1QL queries.

Query Consistency and Reading Your Writes In order to make query execution as quick as possible, queries are executed against an index. When documents are created, removed, or otherwise modified, the index is updated asynchronously.