Integrating search into your app
If your web application deals with a lot of content, it might be a good idea to let your users search it.
When adding search functionality to your application, a key decision is to define your search index. In other words, the way of collecting, parsing, and storing data to enable its fast retrieval. The choice depends on the complexity and requirements of your project.
In this article, you'll learn about two approaches to integrating search into your app:
- Using an external search service and Kentico Kontent webhooks
- Filtering content within your app
Table of contents
The recommended approach is to use a dedicated external search service. It works for small and large projects and can scale as you go. The search service holds your search index, performs search operations over the index, and returns results.
The service can provide you with advanced features such as typo tolerance or custom ranking of the search results. Also, it often comes with SDKs and tutorials to help you integrate it within your app.
To ensure the search index stays up to date, you can use webhooks to automate the process of updating the index with the latest versions of content in your Kentico Kontent project.
Example scenario: You set up a webhook in your Kentico Kontent project with
https://myapp.com/webhook as the webhook URL address. When published content is changed in the project, your app receives a message with metadata about the modified content. Based on the information in the message, your app can determine whether to update the search index with new content or delete content that was archived in the Kentico Kontent project.
Learn how to integrate a search service into your app from worked examples in our blog posts.
- Searching Content with Kentico Cloud: Algolia Integration – walks you through adding Algolia search service into an ASP.NET MVC application and updating search index in reaction to webhook messages.
- Automate Azure Search index updates with webhooks – shows how you can use Azure Functions, Azure Search, and webhooks in a .NET web app.
In-app filtering can work well for smaller web applications and single page applications (SPAs). For example, if you have a smaller project (up to 100 content items) and don't need a robust search, you can cache the content from your Kentico Kontent project in your app and filter it during the app's runtime.
With this approach, you gain control over the search index and its content. Using an existing search library in your app can help. However, it also means that to change the search behavior, you often need to adjust your code manually or replace the search library with another one.
When you need to add search to your web app, an external search service fits the bill in most cases. After you complete the initial integration with the service and add logic for reacting to webhook messages, you get a search with an index that's automatically updated.
With mobile apps, both approaches can be combined at the same time. If your app is online, it can fetch search results using a search service. When offline, the app can fallback to in-app filtering of the content that's available or was searched for previously.