Query
To query a resource collection, which you can think of as a resource container,
perform an HTTP GET and accept a JSON response including at least a _queryFilter
or _queryId
parameter.
These parameters cannot be used together.
GET /users?_queryFilter=true HTTP/1.1
Host: example.com
Accept: application/json
The endpoint returns the result as a JSON object including a results
array
and other fields related to the query string parameters.
Parameters
You can use the following query string parameters:
Parameter | Description |
---|---|
|
Return only the specified fields in each element of the The If the |
|
The string is an opaque cookie to keep track of the position in the search results.
The service returns the cookie in the JSON response as the value of In the request Use this parameter with the The |
|
When The |
|
Return query results in pages of this size. After the initial request, use |
|
Format the body of the response. |
|
Query filters request entries matching the filter expression. You must URL-escape the filter expression. Learn more in Filter expressions. |
|
Specify a query by its identifier. Specific queries can take their own query string parameter arguments depending on the implementation. |
|
Sort the resources returned based on the specified field(s) in As ascending order is the default, including the
The |
|
When a non-zero The
If no count policy is specified in the query, or if |
Filter expressions
Query filters request entries matching the filter expression. You must URL-escape the filter expression.
The string representation is summarized as follows:
Expr = OrExpr
OrExpr = AndExpr ( 'or' AndExpr ) *
AndExpr = NotExpr ( 'and' NotExpr ) *
NotExpr = '!' PrimaryExpr | PrimaryExpr
PrimaryExpr = '(' Expr ')' | ComparisonExpr | PresenceExpr | LiteralExpr
ComparisonExpr = Pointer OpName JsonValue
PresenceExpr = Pointer 'pr'
LiteralExpr = 'true' | 'false'
Pointer = JSON pointer
OpName = 'eq' | # equal to
'co' | # contains
'sw' | # starts with
'lt' | # less than
'le' | # less than or equal to
'gt' | # greater than
'ge' | # greater than or equal to
STRING # extended operator
JsonValue = NUMBER | BOOLEAN | '"' UTF8STRING '"'
STRING = ASCII string not containing white-space
UTF8STRING = UTF-8 string possibly containing white-space
JsonValue components of filter expressions follow
RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format.
In particular, as described in section 7 of the RFC, the escape character in strings is the backslash character.
For example, to match the identifier test\
, use _id eq 'test\\'
.
In the JSON resource, the \
is escaped the same way: "_id":"test\\"
.
When using a query filter in a URL, notice the filter expression is part of a query string parameter.
URL-encoded the filter expression.
Learn more in
RFC 3986: Uniform Resource Identifier (URI): Generic Syntax.
For example, whitespace, double quotes ("
), parentheses, and exclamation characters need URL encoding.
The following rules apply to URL query components:
query = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
ALPHA
, DIGIT
, and HEXDIG
are core rules of
RFC 5234: Augmented BNF for Syntax Specifications:
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
DIGIT = %x30-39 ; 0-9
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
As a result, a backslash escape character in a JsonValue component
is percent-encoded in the URL query string parameter as %5C
.
To encode the query filter expression _id eq 'test\\'
, use _id+eq'test%5C%5C'+
, for example.
A simple filter expression can represent a comparison, presence, or a literal value.
For comparison expressions use json-pointer comparator json-value, where the comparator is one of the following:
eq
(equals)
co
(contains)
sw
(starts with)
lt
(less than)
le
(less than or equal to)
gt
(greater than)
ge
(greater than or equal to)
For presence, use json-pointer pr to match resources where:
-
The JSON pointer is present.
-
The value it points to is not
null
.
Literal values include true (match anything) and false (match nothing).
Complex expressions employ and
, or
, and !
(not), with parentheses, (expression)
, to group expressions.