Integrating search into your app

April 25, 2019

Jan Cerman

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 Cloud webhooks

Filtering content within your app

Table of contents

Search services

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 Cloud project.

Example scenario: You set up a webhook in your Kentico Cloud 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 Cloud project.

Worked examples

Learn how to integrate a search service into your app from worked examples in our blog posts.

In-app filtering

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 Cloud 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.

Summarized

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.

What's next?

Configure webhooks in your Kentico Cloud project so that your app can react to changes in published content.