Skip to main content
Warning This document has not been updated for a while now. It may be out of date.
Last updated: 9 Jun 2020

search-api: How Search Works

Search API provides a /search endpoint for users to of the API to search for documents.

You can also use /batch_search to send multiple queries.

Document retrieval

On receiving a request to /search (a search query), Search API will parse the query, construct an Elasticsearch query, and then retrieve documents from Elasticsearch.

Search API provides a simplified API so that other applications in the GOV.UK stack don't need to know how to construct Elasticsearch queries.

Relevancy

See the relevancy documentation to learn more about how Search API determines how relevant a document is to a query.

Reranking

Once Search API has retrieved a selection of relevant documents from Elasticsearch, the results are re-ranked by a machine learning model.

This process ensures that we show the most relevant documents at the top of the search results.

See the learning to rank documentation to learn more about the reranking model.

Evaluating search quality

To ensure Search API returns good quality results, we use a combination of offline and online metrics.

See the search quality metrics documentation to learn more about our metrics.

The ab_tests parameter can be used to distinguish between two versions of the search query.

Using search-performance-explorer, you can compare the results side by side.

The health check script can be used to evaluate Search API using a set of judgments about which documents are 'good' results for some sample queries.