Search Data API

From Metadata Technology Wiki
Revision as of 02:06, 2 March 2021 by Mnelson (talk | contribs) (Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Overview

The data search API provides the ability to perform a free text search for data. The response is broken down by Dataflow, along with the matched Components related to the Dataflow. The Data Search API only includes Dataflows that have data loaded against them, and will only search Codes related to the Dataflow which have series loaded. The result includes the number of series that match each 'hit' within a Dataflow, where the hit is the Component that matched. For example a search for USA may match a Dataflow in the Reporting Country Dimension because there are a number of series which have Reporting Country USA. If there are also Counterpart Countries for the same Dataflow, and they too have series for USA, then this will also be a hit within the same Dataflow - although the series count for each hit may differ depending on the number of series that exist. If the match is on the Dataflow itself, and there are no hits on the individual components, then the series count will be given at the level of the Dataflow.

The searched structures are Dataflows and Codes. The searched properties of these structures are the Ids, Names, and Descriptions (in all languages).

The results of the Search API can be combined with metadata fetched from the structure web service in order to build the presentation for the user. An example of the search API in use can be seen in the Fusion Data Browser.

API

Path

Entry Point /ws/public/datasearch
Access Public
Http Method GET
Response Format JSON
Response Statuses

200 - Success

401 - Unauthorized (if access has been restricted)

500 - Server Error


Query Parameters

Request Parameter Purpose Allowed Values
query The search text Any values allowed
auto If true the response are valid autocomplete options, if false the response is the search results true/false

Auto Complete Response

The response is a JSON array of search options based on the query term

Example: /ws/public/datasearch?query=money&auto=true

[
  "Claims on central government (annual growth as % of broad money)",
  "Claims on private sector (annual growth as % of broad money)",
  "Broad money (current LCU)","Money (current LCU)",
  "Claims on other sectors of the domestic economy (annual growth as % of broad money)"
]

Search Response

The search response is a list a list of results, each result is a match on a Dataflow and a list of Components that matched with the match text, and the number of series that exist for the matched term

Example: /ws/public/datasearch?query=population
Match on multiple Dataflows, multiple Components

{
  "time" : 28,
  "results" : [
    {
      "Dataflow": "urn:sdmx:org.sdmx.infomodel.datastructure.Dataflow=WB:WDI_HEALTH(1.0)",
      "SeriesCount": 17836,
      "Components": {
            "SERIES": {
               "SH_DYN_AIDS_FE_ZS": {
                   "Name": "Women's share of population ages 15+ living with HIV (%)",
                   "SeriesCount": 112,
                   "Match": "Women's share of population ages 15+ living with HIV (%)"
               },
               "SH_H2O_SAFE_RU_ZS": {
                   "Name": "Improved water source, rural (% of rural population with access)",
                   "SeriesCount": 190,
                   "Match": "Improved water source, rural (% of rural population with access)"
               },
               .....
      }
    }
  ]
}

Example: /ws/public/datasearch?query=WDI_HEALTH
Match on the Dataflow (no individual Components)

{
    "time": 4,
    "results": [{
        "Dataflow": "urn:sdmx:org.sdmx.infomodel.datastructure.Dataflow=WB:WDI_HEALTH(1.0)",
        "SeriesCount": 17836,
        "Components": {}
    }]
}