Skip to main content

HOW TO ADD SEARCH TO DRUPAL WEBSITES WITH LUNR.JS

When your website users can quickly find what they are looking for, this naturally transforms into higher conversions. A good user experience consultant will always recommend that you add search to a website.

Read on to discover more details about why search is important. If you're using Drupal, this post will be of special interest to you because we'll describe how to make website search functionality fast and easy to use with Lunr.js.

Why is website search important?

The question "Does my website need a search?" is asked by many customers. On large and complex websites, internal website search is imperative to improve website navigation. The decision to add a search page to a website is especially vital for content-rich websites, e-commerce stores, knowledge bases, etc.

However, it is also very useful for small and medium-sized websites. Here we will discuss how search functionality on any website, when fast and easy enough to use, can benefit its owner:

  • If a user quickly finds what he needs through the search box, he is likely to buy it.
  • Search results give you new ideas about products or services that interest users.
  • You gain information about user behaviour for your marketing strategies.
  • A search function on your website provides you with new SEO keywords.
  • Adding search functionality to a website makes your design more customer-centric.
  • A search box increases session duration and reduces bounce rate.

You can always contact a web development expert like us for a free consultation and further customization of the search function on your website at very affordable prices. We respect your budget and will recommend a fast, easy to use and efficient search solution that will not require additional costs. In the meantime, let's take a look at how to create search functionality on Drupal websites.

How to add a search function to a website created with Drupal?

The answer to the question of how to set up search functionality on a website depends on the CMS you are using. Each CMS has its special extensions that provide the search function.

In Drupal, to create basic search options for smaller sites, it is sufficient to use the built-in search module. It allows your users to search for whole words in Drupal entities (content nodes, users, etc.). You can also specify indexing settings and choose ranking factors such as:

  • Publishing time
  • Comment activity
  • Keyword relevance

By using additional modules, Drupal websites can also get more complex search features such as:

  • Search facets
  • Search by the alternative spelling
  • Similar content suggestions
  • Highlighting of results
  • Search through attachments
  • Multi-site search
  • And much more...

To achieve this, they connect to robust search platforms like Apache Solr or Elasticsearch through contrib modules like Search API Solr Search and Elasticsearch Connector , as well as using modules like Search API, Facets and many more.

Super fast and easy to use internal website search with Lunr.js

In addition to those described above, there are other interesting JavaScript-based options for adding search to a website created with Drupal. They offer specifically fast Drupal search on the client side. One of which is a search functionality based on Lunr.js .

What is Lunr?

Lunr.js is a full-text search library for use in the browser. It is a small but full-featured library that offers excellent search experiences. Lunr.js offers a simple search interface to find the content that best matches your search queries. It requires no server-side search services and no external dependencies.

All JavaScript solutions are known for their exceptional speed, and Lunr is no exception. Lunr.js search functionality is especially good for cases where instant Drupal search is needed.

An overview of Lunr.js search features

  • Instant search results with suggestions
  • Client-side search without overloading Drupal
  • Keyword-based search
  • Partial and fuzzy search options
  • A scoring system to display relevant results
  • Page development 
  • Location history
  • Slow loading search results
  • And more

Modules for integration between Lunr.js and Drupal

Lunr Search

The Lunr search module integrates Lunr.js with Drupal. It uses Drupal Views to precompile a search index and search results pages. These are delivered to the client via JavaScript. Features include no-configuration multilingual support, fielded searches, custom facets, and more.

Lunr Search API

The Search API Lunr module provides a Search API backend Lunr search with configurable fields. Instead of adding content to a search back-end, JSON files are loaded directly into the browser.

Add a search function to your website with us!

Ready to give your website a new lease of life by adding search functionality? We are ready to do it at affordable prices.

JavaScript frameworks are another passion of our team because we know they can enrich your search box, like any other website element, with special speed and interactivity.

Contact us and let's discuss your best price!