In this tutorial, you will learn how to use the EpiFind APIs to query for indexed content. The aim of this post is for developers who are using EpiFind. If you've stumbled across this post and you are more interested in simply learning more about EpiFind, I suggest you read this article, Review Of The Different Search Providers Available To Use On Your Episerver Project. In this post, I will share some basic code snippets to query EpiFind.

Performing A Basic Search Query

Performing a search query using Find is pretty easy. The best approach to access Find data is to inject the Find API, IClient into your class. In the example below, I'm returning a PageData object. With PageData you get access to all standard page related properties. The code to do this is shown below:

For those of you who are interested, there is also a legacy way of accessing the same API. This approach uses a singleton approach to API access using something called SearchClient. I suggest you avoid this route, however, it's useful to understand it exists, especially when reading blog posts on Find!

Querying EpiFind results in an object of type ContentResult being returned. ContentResultcontains all the results as well as meta-data about the query. It includes several useful bits of data, like related facets and the total number of results. To access the search result data items, you can use this snippet:

You can get the total number of results returned, like this:

If you want to only search Find for certain content-types, you can use this code:

To get access to the related facets, you can use this snippet:

Eivind is very simple to get started with and offers a pretty powerful API. In today's post, I've covered some of the basic ways to query Find and display search results on your website. Happy Coding 🤘