Selecting fields
It is possible to specify which fields should be returned in the response.
For that, it is necessary to specify select
parameter with string of fields separated by comma.
All fields you receive in response (results) are available for selection.
To return some nested fields of some other field it is possible to declare nesting by /
symbol.
In case if field and his nested fields are selected in one query, only the root field will affect.
Examples:
-select=image/dataGovernance/source/link,image/dataGovernance
- in that case image/dataGovernance/source/link
will be ignored
-select=image/dataGovernance
Information
Max depth of supported fields nesting is 7. (e.g. for root/nested1/nested2/nested3/nested4/nested5/nested6/nested7/nested8
query nested7
and following will be ignored)
Warning
link
property doesn't support nested selecting (properties like link.url
, link.type
will be ignored).
Selecting several root fields¶
link:
https://api.discover.swiss/info/v2/search?type=Tour&select=@id, image, dataGovernance
link:
https://api.discover.swiss/info/v2/search
body:
{
"type":"Tour",
"select":"@id, image, dataGovernance"
}
{
"values": [
{
"@id": "https://api.discover.swiss/info/v2/tours/TOUR_ID",
"dataGovernance": {
"supplier": {
"acronym": "ACRONYM"
},
"source": {
"name": "Name",
"logo": {
"contentUrl": "link"
},
"link": [
{
"url": "link",
"type": "type"
}
]
},
"author": "author"
},
"image": {
"caption": "caption",
"dataGovernance": {
"supplier": {
"acronym": "ACRONYM"
},
"source": {
"link": [
{
"type": "type"
}
]
}
},
"contentUrl": "contentUrl",
"thumbnailUrl": "thumbnailUrl",
"@id": "https://api.discover.swiss/info/v2/imageObjects/IMAGE_ID",
"identifier": "IMAGE_ID"
}
},
{
...
}
]
}
Selecting root and nested fields¶
link:
https://api.discover.swiss/info/v2/search?type=Tour&select=dataGovernance/source, dataGovernance/source/name
link:
https://api.discover.swiss/info/v2/search
body:
{
"type":"Tour",
"select":"dataGovernance/source, dataGovernance/source/name"
}
The response will return all properties under dataGovernance/source
. Selection of more specific property dataGovernance/source/name
will be ignored:
{
"values": [
{
"dataGovernance": {
"source": {
"name": "name",
"logo": {
"contentUrl": "contentUrl"
},
"link": [
{
"url": "url",
"type": "type"
}
]
}
}
},
{
...
}
]
}