Query string options
OData supports various kinds of query options for querying data. System query options are query string parameters that control the amount and order of the data returned for the resource identified by the URL. The names of all system query options are prefixed with a dollar character, ($). A query string starts with a question mark (?), and the query options are separated by an ampersand (&). The asterisk (*) is used to specify all values. Each query option can be set on a particular value with (=).
A query string option (QueryOptions – Figure 2) can be represented in this way:
$query_option_A{=value_1}&…&$query_option_N{=value_2} |
The query options admitted by the Data Hub service are listed in the following Table and described below:
Query Option | Description |
$top | determines the maximum number of records to return |
$skip | requests the number of items in the queried collection that are to be skipped and not included in the result |
$count | allows clients to request a count of the matching resources included with the resources in the response |
$select | specifies a subset of properties to return /allows clients to requests a specific set of properties for each entity |
$format | specifies the HTTPS response format e.g. XML or JSON /allows clients to request a response in a particular format |
$orderby | allows clients to request resources in either ascending or descending order |
$search | restricts the result to include only those entities matching the specified search expression. The definition of what it means to match is dependent upon the implementation |
Table 4 – Query Options
Query option $top
A data service URI with a $top System Query Option identifies a subset of the Entities in an EntitySet identified by the Resource Path section of the URI.
This subset is formed by selecting only the first M items of the set, where M is an integer greater than or equal to zero specified by this query option. If a value less than zero is specified, the URI should be considered malformed.
Syntax:
https://catalogue.onda-dias.eu/dias-catalogue/Products?$top=<M> |
ONDA example:
List the last 10 Sentinel-1 products published on the ONDA Catalogue: https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=%22name:S1*%22&$top=10 |
Query option $skip
A data service URI with a $skip System Query Option identifies a subset of the Entities in an EntitySet identified by the Resource Path section of the URI.
That subset is defined by seeking N Entities into the EntitySet and selecting only the remaining Entities (starting with Entity N+1). N is an integer greater than or equal to zero specified by this query option. If a value less than zero is specified, the URI should be considered malformed.
The syntax is:
https://catalogue.onda-dias.eu/dias-catalogue/Products?$skip=<N> |
A client can request a particular page of items by combining $top and $skip.
Query option $count
The $count system query option allows clients to request a count of the matching resources included with the resources in the response.
Syntax:
https://catalogue.onda-dias.eu/dias-catalogue/EntitySet/$count |
ONDA example:
Total number of all products in the ONDA Catalogue:
https://catalogue.onda-dias.eu/dias-catalogue/Products/$count Total number of Sentinel-2 products in the ONDA Catalogue: https://catalogue.onda-dias.eu/dias-catalogue/Products/$count?$search=”name:S2*” |
Query option $select
The $select system query option allows the clients to requests a limited set of properties for each entity. The value of a $select System Query Option is a comma-separated list of selection clauses.
Syntax:
https://catalogue.onda-dias.eu/dias-catalogue/Entity?$select=Property_1[,Property_2] |
ONDA example:
Querying the ID property of all the Products
https://catalogue.onda-dias.eu/dias-catalogue/Products?$select=id Querying the Name and CreationDate properties of all the Products https://catalogue.onda-dias.eu/dias-catalogue/Products?$select=name,creationDate |
Query option $format
The $format system query option allows clients to request a response in a particular format. The default format is XML. Valid values for the $format query string option are:
- atom,
- xml,
- json
ONDA example:
Display all products in the archive in Json format:
https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=json Display all products in the archive in XML format: https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=xml |
Query option $orderby
The $orderby system query option allows clients to request resources in either ascending or descending order.
Syntax:
https://catalogue.onda-dias.eu/dias-catalogue/Entity?$orderby=property [asc|desc] |
ONDA example:
Querying product sorted by ascending creation date
https://catalogue.onda-dias.eu/dias-catalogue/Products?$orderby=creationDate%20asc |
Query option $search
A URI with a $search System Query Option identifies a subset of the Entities from an EntitySet identified by the Resource Path section of the URI. The subset is determined by selecting only the Entities that satisfy the predicate expression specified by the query option.
Syntax:
https://catalogue.onda-dias.eu/dias-catalogue/Entity?$search=”<keyword>:<values> [AND <keywork> :<value>]” |
Depending on the keyword, the value(s) can be specified as a single value or range of values.
Search keywords can be combined with each other using Operators.
ONDA example:
Querying Products in a specific creation date range |
Querying Sentinel-1 MSI Products
https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=”instrumentShortName:MSI” |
Querying Sentinel-3 SRAL Products
https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=”instrumentShortName:SRAL” |
Querying products with SLC product type
https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=”productType:IW_SLC__1S” |
Querying specific text in product name
https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=”name:*text*” |
Querying specific text in product metadata
https://catalogue.onda-dias.eu/dias-catalogue/Products?$search=”*text*” |