Refinements in the Search API

Learn how we can evolve the search API by adding new features.

The purpose of this lesson is to learn how we can enhance the functionality of the search API by adding a new feature. Our API already supports some basic features. For example, sorting improves the user experience, whereas pagination reduces unnecessary load on the network. However, we need a feature that allows our users to refine the search criteria to find specific data.

To achieve that, we’ll need to add the filtering functionality along with appropriate versioning.

  • Filtering: This section introduces filtering, its types, and discusses how clients can interact with the search service to request filtering.

  • Versioning: This section focuses on versioning and discusses the versioning semantics required to support filtering.

Let's start with how to add filtering to the existing design of the search API.


Filtering is the process of restricting search results based on the user's requirements or criteria. It is a crucial ability in the search feature. For example, it’s possible to filter search results to return only images and videos.

There are two types of filtering:

  • Simple filter: In simple filtering, the search query filters results on the basis of a single entity. For example, if the user wants to see only "data structure" courses of the "intermediate" level, the query string for this search is set to "data structure," whereas the filter value is set to "intermediate.”

  • Complex filter: In complex filtering, the search query filters results on the basis of a defined range. For example, if the user wants to see courses in a certain price range (for instance, $20 to $30), then the search API should return the courses in the specified price range.

Let's look at the details of each filtering technique.

Simple filters

Simple filters require us to provide attributes to the API based on the type of filtering that is performed. For example, on educational websites, we have multiple attributes, like course level, author, and so forth. If we want to filter data on the basis of the course level, then the client can send a request using the following URL:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy