Searching
Properties names should be in CamelCase.
Warning
When you are searching in a specific language don't forget to set up the necessary language in Accept-Language
header, otherwise you can receive an incorrect response.
Search samples¶
Search with pagination and ordering by property name¶
link:
https://api.discover.swiss/info/v2/search?orderBy=time&type=Tour&select=identifier,time
link:
https://api.discover.swiss/info/v2/search
body:
{
"orderBy": "time",
"type": "Tour",
"select": "identifier,time"
}
Fulltext search¶
link:
https://api.discover.swiss/info/v2/search?searchText=Scuol, Gurl* +"Tarasp fontana" -spaceship
link:
https://api.discover.swiss/info/v2/search
body:
{
"searchText": "Scuol, Gurl* +\"Tarasp fontana\" -spaceship"
}
The query parser separates operators (such as *, + and - in the example) from search terms, and deconstructs the search query into subqueries of a supported type:
- term query for standalone terms (like Scuol)
- phrase query for quoted terms (like Tarasp fontana or)
- prefix query for terms followed by a prefix operator * (like Gurl)
Search by selected language¶
To search by the language it is necessary to specify Accept-Language
header and set searchText
.
link:
https://api.discover.swiss/info/v2/search?searchText=Switzerland&type=AdministrativeArea
headers:
{
"Accept-Language": "en"
}
link:
https://api.discover.swiss/info/v2/search
headers:
{
"Accept-Language": "en"
}
body:
{
"searchText": "Switzerland",
"type": "AdministrativeArea"
}
Search by selected fields¶
There is a possibility to specify SearchFields
if you want to search by a specific field.
Information
Search is using all searchable fields when SearchFields
is empty.
The searchable fields are available searchable fields:
Field name | Translated |
---|---|
openingHours | - |
address/name | + |
address/addressLine | - |
address/streetAddress | - |
description | + |
disambiguatingDescription | + |
name | + |
Translated field means that this property is available in different languages.
For declaring multiple fields in searchFields
property they should be separated by a comma:
searchFields=name, description
searchFields=name, address/name, description
searchFields=address/name
Sample of searching by single fields¶
link:
https://api.discover.swiss/info/v2/search?searchText=Schweiz&searchFields=name&type=AdministrativeArea
link:
https://api.discover.swiss/info/v2/search
body:
{
"searchText": "Schweiz",
"searchFields": "name",
"type": "AdministrativeArea"
}
Sample of searching by multiple fields¶
link:
https://api.discover.swiss/info/v2/search?searchText=Schweiz&searchFields=name, address/name
link:
https://api.discover.swiss/info/v2/search
body:
{
"searchText": "Schweiz",
"searchFields": "name, address/name"
}