I have always been concerned about the "weak" search function that comes with WordPress. The search results are not very relevant and the results are not accurate enough. Moreover, the search function that comes with WordPress cannot search tags, categories, and other content. The search results can be listed in chronological order. Sometimes it is really troublesome to find things.

Usually in order to enhance the search function that comes with WordPress, we will use the custom search of Baidu and Google. I have previously introduced it in detail in the article Baidu, Google custom search and Elasticsearch self-built search. Friends who are interested can read it. . But there are two fatal problems with using Baidu and Google custom searches:

First, Baidu site search does not support Https, although there are many methods on the Internet that use nginx reverse generation (interested friends can read this article: Nginx reverse binding, cache acceleration, automatic cache update and obtaining real IP) to solve the problem. There is a problem with HTTPS calls, but the process is too complicated, and there are also problems such as the inability to open images and additional charges.

The second is that Google custom search cannot be used in China. This item basically "abolishes" Google on-site search. Two large search engines cannot be used, so we found a niche search engine: Algolia. Algolia was founded in 2012 by Nicolas Desseny and Julien Lemoine from Paris, France. In the early days, its main business was offline search on mobile phones.

Use Algolia to add real-time on-site search function to WordPress-higher search quality and more accurate content

Algolia now has 47 data centers in 15 regions. It provides services to more than 1,600 customers and handles 12 billion user query requests every month. Customers mainly come from e-commerce and other fields. For domestic users, it is common for Hexo static blogs to use Algolia on-site search, and it is quite simple for WordPress to integrate Algolia on-site search.

For more articles about WordPress optimization, here are:

  1. DirectAdmin space enables OpCache and redis cache acceleration - WP enables redis cache
  2. The WordPress plug-ins I am using - WP SEO, CDN, caching, pictures, emails, forum plug-ins
  3. WordPress uses MailPoet to build its own RSS update email notification system - user subscription and management

PS: Updated on September 15, 2019, if your WordPress article is relatively long, it is very necessary to add a directory navigation at this time: WordPress article directory side fixed scrolling-Easy Table and LuckyWP Table plugin.

PS: Updated on December 2, 2019, If you want to build a more powerful and faster free on-site search, you can also try RediSearch high-performance full-text search engine: RediSearch high-performance full-text search engine Search Engine - Integrate with WordPress to create high-quality search.

1. Register and use Algolia

website:

  1. Official website: https://www.algolia.com/

To use the Algolia on-site search engine, we first need to register an account.

Algolia provides a free version, which contains 50,000 queries and 10,000 records. It can basically only be used by a small blog. Large websites are better off using their paid version.

Go to Algolia's account management interface to find the APIs and note them down.

2. WP integrates Algolia

2.1 Install plug-ins

  1. HTTPS://WordPress.org/plugins/I'm afraid-search-with-Aragon Oh Two/

There are many plug-ins for WordPress to integrate the Algolia search engine. Here wzfou.com uses this plug-in: WP Search with Algolia. After enabling the plug-in, click Algolia on the left navigation bar to make related settings for Algolia.

2.2 Indexing

After filling in the Algolia API information, choose and click "Automatic Indexing". Here Algolia allows you to specify the sections and data to be indexed. In addition to WordPress articles, tags and categories, we can also add forums, products, etc. , use it if you have a WooCommerce store. (Click to enlarge)

2.3 Enable Algolia

WordPress supports two ways to enable Algolia search: one is to retain the search that comes with WordPress. Algolia is only used as an instant search. When the user searches for content, Algolia will instantly display the drop-down search results, but when the user clicks submit, the search results of WordPress will still be displayed.

The other is Algolia replacing WordPress's own search. After clicking submit, you will go to Algolia's search results page, and users can also continue to search for content on this page. The disadvantage of this method is that you need to modify the CSS yourself so that Algolia can be fully integrated into WordPress.

3. Algolia real-time search

The effect of Algolia real-time search can be seen in the upper right corner of this site. The picture below shows the real-time search results in Algolia site:

4. Summary

As a third-party search engine, Algolia can be perfectly embedded into WordPress and replace WordPress’s own search function. The WP Search with Algolia plug-in will automatically incorporate new WordPress content into Algolia, and search results will be displayed in real time.

The Algolia search engine is easy to use, but its free quota is actually not very large. After the Algolia search is enabled in WordPress, more than half of the operation records are basically used up. If your website traffic is larger, Algolia’s search requests may be very large. It will be used up soon.

Leave a Reply