Skip to main content

How to add search to your website on Drupal with superfast Lunr.js

Blog image

When your website users can quickly find what they are looking for, you naturally get more conversions. A good UX consultant will always recommend you add search to your website.

Read on to discover more details about why search is important. If you are using Drupal, this post will be of special interest to you because we will describe how to make the website search functionality fast and user-friendly with Lunr.js.

Why is search important on a website?

Many customers ask 'Does my website need search?'. On large and complex websites, an internal website search is a must-have to improve website navigation. The decision to add a search box to a website is especially vital for content-rich websites, e-commerce stores, knowledge bases, and so on.

However, it is also very helpful for small and medium-sized websites. Here we will discuss the ways search functionality on any website, when it is fast and user-friendly enough, can benefit its owner:

  • If a user finds what they need through the search box quickly, they are likely to purchase it.
  • Search results give you new ideas about products or services users are interested in.
  • You get information about user behavior for your marketing strategies.
  • A search feature 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 your session duration and reduces the bounce rate.

You can always reach out to our web development team for a free consultation and further creation of a search feature 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 extra costs. Meanwhile, let’s discuss how search functionality is created on websites.

How to add a search to your website built with Drupal?

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

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

  • publication time
  • activity in comments
  • keyword relevance

Through the use of extra modules, Drupal websites can also get more complex search features like:

  • faceted search
  • search by alternate spellings
  • similar content suggestions
  • result highlighting
  • search through attachments
  • multisite 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.

Superfast and easy-to-use internal website search with Lunr.js

In addition to the ones described above, there are other interesting, JavaScript-based options to add a search function to a website built with Drupal. They offer specifically fast client-side search. One of these we are sharing with you right now — your Drupal can have a search functionality based on Lunr.js.

What is Lunr?

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

You might have noticed its “lunar” brand design. Lunr.js is an alternative to the famous search engine Solr. “A bit like Solr, but much smaller and not as bright,” is the official slogan of Lunr.

Lunr.js

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

A sum-up 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 for showing relevant results
  • paging
  • location history
  • lazy-loading search results
  • and more

Modules for the integration between Lunr.js and Drupal

  • Lunr search

The Lunr search module integrates Lunr.js with Drupal. It uses Drupal Views to pre-build a search index and the search result pages. These are delivered to the client using JavaScript. Its features include no-configuration multilingual support, custom field/facet searches, and more.

Lunr search Drupal module
  • Search API Lunr

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 search to your website with our experts!

Ready to give your website a new boost by adding search functionality? Our website support agency experts are ready to do it at affordable prices.

We have both developers who specialize in Drupal and those who have mastered WordPress. 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!