Blogs

To know about all things Digitisation and Innovation read our blogs here.

Blogs Using Search API to enhance search functionality on the Developer Portal
API

Using Search API to enhance search functionality on the Developer Portal

SID Global Solutions

22 January 2022

Using Search API to enhance search functionality on the Developer Portal

Using Search API to enhance search functionality on the Developer Portal

1. Out of the box- Search

Apigee Developer Portal based on Drupal ships with Drupal core search module. The search module lets users search for specific content on your site. You can search both for users and for particular words. When you are on the “content” tab of Search, you will be able to search for words appearing in the default rendering of node content on your site, which would include the default rendering of any fields, Taxonomy, etc., as well as comments.

2. Search API Implementation

Search API module with a reported usage by over 100,000 sites is a really good tool to enhance search on any Drupal platform. This module is designed to replace the core “Search” module with a flexible framework that can be easily customized and extended. As a matter of fact, Drupal.org uses Search API in conjunction with Search API Database Search.

A. Requirements

  • For installing the Search API, you will need the Entity API module already installed and enabled.
  • For setting up a server (and therefore actually using the Search API), you will also need a module providing a service class or backend, like the database servicemodule.

B. Search API administration page

  • After you have enabled the Search API module, click the “Configure” link next to the module’s name in the module list to go to Search API’s administration page. This pagelists “servers” and “indexes”, and is the place where you will make most Search APIconfigurations. You can also reach it at Administration > Configuration > Search and metadata > Search API (or http://yourdevportal.com/admin/config/search/search_api).
  • Go to Search API’s administration page at Administration > Configuration > Search and metadata > Search API (or http://example.com/admin/config/search/search_api).

C. Add Server

  • Click Add server to go to the server creation form. Here, you have to enter some information for your new server:

D. Adding an index

  • Go to Search API’s administration page at Administration > Configuration > Search and metadata > Search API (or http://yourdevportal.com/admin/config/search/search_api).If you are on this page the first time after installing the module, you will notice there is already a default index set up by the module, the Default node index. You can use this index and edit it to your needs instead of creating a new one. Its default settings should be appropriate for most basic cases when you want to search content on your site. Specify Database Server, created in the previous step to be used as the server for this index.

E. Creating a View using Search API

  • Enable the search_api_views submodule at admin/modules

  • Create a new View: admin/structure/views/add
  • View name: Search APIs
  • Show: Default node index
  • Create a page [tick]
  • Page title: Search APIs
  • Path: search-apis
  • Display format: Unformatted list of Rendered entity
  • Items to display: 15, use pager

  • Continue & edit (the new View)
  • Format: Show: Rendered entity | Settings

Filter criteria
  • Fulltext search: Expose this filter, Required, Remember the last selection, Use as: search keys
Sort criteria
  • Search: Relevance, descending
  • Page settings
  • Access: Permission: view published content

Advanced
  • No results behavior: Global: Text area “No results matched your search input.”

In Action

Author: Dharma Teja Adusumilli – SIDGS Digital Practice

Read More: Why Digital Transformation is a Must for Enterprises?

Need help with Apigee, DevOps, CI/CD, Microservices, UI/UX, GCP, Kubernetes, Docker, Istio, AWS, Drupal, AI/ML, Mobile AppDev, and other Digital Solutions? – Contact us at info@sidgs.com

Stay ahead of the digital transformation curve, want to know more ?

Contact us

Get answers to your questions