Skip to content

search api overview

Search api as part of the Infocenter is designed to speed up database searches. We are using Azure Cognitive Search

https://api.discover.swiss/info/v2/search

There are GET and POST endpoints for search.

Sample application

You can see search in sample application: demo.discover.swiss/search

Search request

Parameter Type Description
searchText string Optional. Search for contained string by the searchable fields
searchFields string Optional. When name of fields are specified as a comma separated string (e.g. "name, description, address/name") then only the selected fields will be used for searching.
select string Optional. When name of fields are specified as a comma separated string (e.g. "name, description, @id, address") then only the selected fields will be returned.
filters string[] Optional. Odata strings for filters
currentPage int Optional. By default equal 1. Determines how many results are in response
resultsPerPage int Optional. By default equal 10. Determines how many results are in response
orderBy string Optional. Determines name of field by which result will be ordered
facets FacetRequest[] List of facets which will be in the response
scoringTags string[] List of tags which will be used for scoring (Beta) of results in the response

Custom filter properties

Parameter Type Description
datasource string[] Optional. Determines one or many datasources used to filter data
project string[] Optional. Determines one or many projects used to filter data
category string[] Optional. Determines one or many categories used to filter data
campaignTag string[] Optional. Determines one or many campaign tag by which data will be filtered
profileTag string[] Optional. Determines one or many profile tag by which data will be filtered

Facets filter properies

For filtering by facets it is necessary to use porerty filterPropertyName from Search facet response as a request property name. These filter properties are optional.

List of available facets filters

facet name filter property name filter value type description
address/addressLocality addressLocality string[]
address/postalCode addressPostalCode string[]
tag tag string[]
categoryTree categoryTree string[] represent category tree list. For getting full list of categories don't forget to set big enough value for count property in facet request
containedInPlace/id containedInPlace string[]
time time int[]
state state string[]
rating/condition ratingСondition int[]
rating/difficulty ratingDifficulty int[]
elevation/ascent elevationAscent int[]
elevation/descent elevationDescent int[]
elevation/minAltitude elevationMinAltitude int[]
elevation/maxAltitude elevationMaxAltitude int[]
season season string[]
type type string[]
combinedType combinedType string[] represent array containing data from parentType and parentAdditionalType properties
combinedTypeTree combinedTypeTree string[] represent array containing tree data from parentType and parentAdditionalType properties
leafType leafType string[] contains additionalType or type

Localization

Default value

de-CH

Language: Based on the Accept-Language header localized properties are translated. Search language is based on this header as well (e.g. for de-CH it will search only in german translations if the translation is available for this porperty.

Search response

Any search response contains list of possible filters and total number of results matching current query.

Property name Type Description
count int (nullable) actual count of results in actual query but not count possible results
values SearchValueResponse[] paged count of results by query
facets {string, SearchFacetResponse}[] Dictionary of facets by the query. Where the key is a string with name of facets from azure search, and the value is SearchFacetResponse

Search index definition

Property name Type Retrive Search Filter Facet Sort
datasource string + +
project string[] +
type string + + +
combinedType string[] + +
combinedTypeTree string[] + +
leafType string + +
additionalType string + +
identifier string +
@id string +
address(/addressLocality) object(string) + + +
address/postalCode object(string) + + +
address/(name/{de/en/fr/it}) object(string) + +
address/addressLine object(string) + +
address/streetAddress object(string) + +
geo GeographyPoint + +
name/{de/en/fr/it} string + + +
description/{de/en/fr/it} string + +
disambiguatingDescription/{de/en/fr/it} string +
openingHours string + +
schedule(/byDay) object + +
schedule(/startDate) object + +
schedule(/endDate) object + +
schedule(/startTime) object + +
schedule(/endTime) object + +
image ImageObject +
tag string[] + +
campaignTag string[] +
profileTag string[] +
allTag string[] +
category string[] +
categoryTree string[] + +
containedInPlace(/id) object + +
dataGovernance DataGovernance +
ouaId int +
time int + + + +
state string + + +
rating(/condition) object(int) + + +
rating(/difficulty) object(int) + + +
elevation(/ascent) object(int) + + + +
elevation(/descent) object(int) + + +
elevation(/minAltitude) object(int) + + +
elevation(/maxAltitude) object(int) + + +
season string[] + +
link Link[] +

Warning

{de/en/fr/it} - means that this property is available on the different languages

Information

Type definition object(string) for properties like address(/addressLocality) means that type of address is object and type of /addressLocality property is string.

Searching

There is possibility to use text search in search api.

Read more about searching here

Filtering

Search api supports filtering by exact fields of search model.

Read more about filtering here

Facets

There are facets in response which can be used for filtering and more.

Read more about facets here

Selecting of fields for result

It is possible to specify which fields should be returned in the response. Read more about selecting fields here

Scoring profile (Beta)

It is available to prioritize results of search by profile tags using scoringTags request parameter When scoringTags have values in request, all values in response with profile tags equal to values from scoringTags will be moved to the top of search results.

How to use

link:

https://api.discover.swiss/info/v2/search?scoringTags=profile-sport-1&scoringTags=profile-sport-3

link:

https://api.discover.swiss/info/v2/search

body:

{
    "scoringTags": ["profile-sport-1", "profile-sport-3"]
}

Last update: February 18, 2021 19:36:04