# Tutorials for Joomla!

# Basic Configuration

# Video Tutorial: Basic Configuration for Joomla!

# STEP 1: Create an Algolia account

Go to Algolia (opens new window) and create your account.

In the Algolia Dashboard you will find your API Keys:

  • Application ID: This is your unique application identifier. It's used to identify you when using Algolia's API.
  • Search-Only API Key: This is the public API key to use in your frontend code. This key is only usable for search queries.
  • Admin API Key: This is the ADMIN API key. Please keep it secret and use it ONLY from your backend: this key is used to create, update and DELETE your index. You can also use it to manage your API keys.

Algolia Keys

You also need to create your Index, go to Indices and create it.

  • Index: Where the data is indexed and the search parameters configured.

Algolia Indices

Algolia Indices

# STEP 2: Configure the XT Search for Algolia

Go to XT Search for Algolia, click on Options and fill the Application ID, Search-Only API Key, Admin API Key and Index Name:

XT Search Configuration

  • Connectors Configuration: To define the extension that is going to be indexed by XT Search in Algolia and other associated parameters that control the connector.

Connectors Configuration

# STEP 2.1: Configure the content connectors

XT Search for Algolia comes with a growing set of content connectors. They are used to look for and retrieve the available content items. Select the required connectors and configure the optional filters if it is necessary.

Configure the content connectors

# STEP 3: Index Generation

When the Connector and Algolia are configured, the extension is ready to be indexed. There are two ways to do it:

  • Manually in the Control Panel
  • Automatically with a Cron Job

# STEP 3.1 Manual Indexing

This method is the simplest and can be executed directly on the backend.

To execute this option, please, click on the button and wait until the process is completed.

Index

Index Progress

At this point, the index records have been generated, and you can browse them in Algolia Dashboard.

# Full, Incremental, or Batch Indexing

There are three alternatives to perform the indexing of records:

  • Full Indexing: If you execute the Full Indexing, all records will be indexed. Additionally, all previous records will be cleared each time it is called. This is the best and the most straightforward option to index all records.
  • Incremental Indexing: This option only indexes new records, following the Options/"Incremental Indexing (Number of Days)" parameter. If you start running out of Algolia ops, you can begin using Incremental Indexing to optimize the process.
  • Batch Indexing: Finally, the last alternative is the Batch Indexing, specially targeted to big set of records. It works similarly to the Full Indexing, but it processes the tasks in batchs to avoid server overloads.

The batch processing also supports the incremental variation.

NOTE

These Cron Job commands execute the indexing operation based on Joomla! command-line. There are extensions that do not support the command-line usage. If you find differences in the results, please, try the alternative Web Front-end processing, for use with CRON (opens new window).

# STEP 3.2 Cron Automation

You can configure the Cron job process to automate the indexation.

Cron

# Overview of CRON jobs

To run smoothly, you will need to set up a CRON job to execute periodically.

TIP

A cron job task can be executed every day or at any given frequency.

There are two ways to execute the CRON job:

  • Command Line Interface (CLI) - Native CRON script (available only on Joomla 3)
  • Web CRON job script

# Native CRON CLI script (available only on Joomla 3)

TIP

Users report that they get no joy using this script on GoDaddy hosting.

If you have access to the command-line version of PHP, XT Search for Algolia (opens new window) includes an even better - and faster - way of indexing your records.

In order to schedule a indexing, you will have to use the following command-line to your host's CRON interface:

where /usr/local/bin/php is the path to your PHP CLI executable and /home/USER/webroot is the absolute path to your web site's root. You can get this information from your host.

In order to give some examples, I will assume that your PHP CLI binary is located in /usr/local/bin/php - a common setting among hosts - and that your web site's root is located at /home/johndoe/httpdocs.

Special considerations:

  • Most hosts do not impose a time limit on scripts running from the command-line. If your host does and the limit is less than the required time to publish from your site, the job will fail.
  • This script is not meant to run from a web interface. If your host only provides access to the CGI or FastCGI PHP binaries, xtsearch_cli.php XTSearchForAlgolia:index will not work with them. The solution to this issue is tied to the time constraint detailed above.
  • Some servers do not fully support this indexing method. The usual symptoms will be a job which starts but is intermittently or consistently aborted in mid-process without any further error messages and no indication of something going wrong. In such a case, trying running the indexing from the back-end of your site will work properly.

# Setting up a CRON job on cPanel

Go to your cPanel main page and choose the CRON Jobs icon from the Advanced pane. In the Add New CRON Job box on the page which loads, enter the following information:

  • Common Settings, Choose the frequency of your indexing, for example once per day.
  • Command Enter your indexing command. Usually, you have to use something like:

where myusername is your account's user name (most probably the same you use to login to cPanel). Do note the path for the PHP command-line executable: /usr/bin/php-cli. This is the default location of the correct executable file for cPanel and later. Your host may use a different path to the executable. If the command never runs, ask them. We can't help you with that; only those who have set up the server know the changes they have made to the default setup.

Finally, click the Add New Cron Job button to activate the CRON job.

# Special considerations for HostGator

The location of the PHP CLI binary is /usr/bin/php-cli. This means that your CRON command-line should look like:

Finally, it should be noted that you can use the command-line override feature to do more tricky configuration overrides, for example turning off the archive splitting or using a different indexing output directory to enhance your security. If it is something you can do in the Configuration page of the component, you can also do it using command-line overrides.

In order to call this script with a schedule, you need to put something like this to your crontab (or use your host's CRON feature to set it up):

Where /usr/local/bin/php is the absolute path to your PHP command-line executable and /home/USER/public_html/cli/xtsearch_cli.php XTSearchForAlgolia:index is the absolute path to the script above.

If you set up your CRON schedule with a visual tool (for example, a web interface), the command to execute part is:

# Web Front-end processing, for use with CRON

TIP

The web-based commands are compatible with Joomla 3 and Joomla 4, and with most extensions.

The front-end processing feature is intended to provide the capability to perform an unattended, scheduled indexing on your site.

The front-end indexing URL performs a single indexing step. You will only see a message upon completion, should it be successful or not. There are a few limitations, though:

TIP

It is not designed to be run from a web browser, but from an unattended CRON script, utilizing wget or CRON as a means of accessing the function.

The script is not capable of showing progress messages.

Before beginning to use this feature, you must set up XT Search to support the front-end indexing option. First, go to XT Search's main page and click on the Component Configuration / Cron Job item. Below it, you will find the option named Base URL Override and Secret word. In that box, you have to enter a password which will allow your CRON job to convince XT Search that it has the right to publish from the call. After you are done, click the Save button on top to save the settings and close the dialog.

TIP

Use only lower- and upper-case alphanumeric characters (0-9, a-z, A-Z) in your secret key. Other characters may need to be manually URL-encoded in the CRON job's command-line. This is error-prone and can cause the indexing operation to never start even though you'll be quite sure that you have done everything correctly.

Most hosts offer a control panel of some kind. There has to be a section for something like "CRON Jobs", "scheduled tasks", and the like. The help screen in there describes how to set up a scheduled job.

TIP

If your host only supports entering a URL in their "CRON" feature, this will most likely not work with XT Search. There is no workaround. It is a hard limitation imposed by your host.

If you are on a UNIX-style OS host (usually, a Linux host), you most probably have access to a command-line utility called wget.

TIP

Do not forget to surround the URL in double-quotes. If you don't the command will fail, and it will be your fault! The reason is that the ampersand is also used to separate multiple commands in a single command-line. If you don't use the double-quotes at the start and end of the indexing URL, your host will think that you tried to run multiple commands and load your site's homepage instead of the front-end indexing URL.

If you are unsure, check with your host. Sometimes you have to get from them the full path to wget in order for CRON to work, thus turning the above command-line to something like:

Contact your host; they usually have a nifty help page for all this stuff. Read also the section on CRON jobs below.

wget is multi-platform command-line utility program. It is frequently included in the operating systems. The wget homepage is here: https://www.gnu.org/software/wget/wget.html (opens new window).

Other alternative commands are:

To execute the incremental indexing with the Web Front-end processing, add the paramenter incremental=1. Check the following examples:

TIP

The ampersands above should be written as a single ampersand, not as an HTML entity (&). Failure to do so will result in a 403: Forbidden error message, and no indexing will occur. This is not a bug. It is the way wget works.

# Free Online CRON Schedulers

If you are still having trouble with the above options, and your hoster does not provide any Cron job support, use any online Cron job scheduler service available on the web. Do not worry about security because what these sites do is merely accessing the Url at a certain interval, which is open to anyone.

TIP

EasyCron (opens new window) is an online Cron Service.

  • Trusted by the Pros.
  • Save your time.
  • Easy to reason about.
  • Alternative to Linux Cron.

EasyCron offers a poweful set of functions:

  • Standard Cron expression
  • 3 ways to specify execution time
  • Email Notification
  • Cron Job Execution Logs
  • Execution Time Prediction
  • Separate Failure Logs
  • Customize HTTP Method
  • Customize HTTP Headers
  • Powerful API
  • Output Regexp Matching
  • Webhook
  • Configure Timeout
  • Timezone Adaptable
  • User-Friendly Interface
  • No Need to Install

# Using the front-end indexing in SiteGround (opens new window) and other hosts using cURL instead of wget

Finding the correct command to issue for the CRON job is tricky. This recipe applies not only to SiteGround (opens new window), but many other commercial hosts as well.

In the CPanel for SiteGround (opens new window) there is a Cron job option, you create a Cron job using that and use:

as your command.

# Using the front-end indexing in SiteGround (opens new window) and other hosts using lynx instead of wget

Lynx is a text-based browser that is installed in most hosting environments.

On most Linux systems, you can simply run the commands below. We would recommend running the CRON every thirty (30) minutes or less. On a busy site, you might want to run it every ten (10) minutes. The more frequently you run it, the less load there will be on the server.

If you do not have Lynx installed, you can use other alternatives such as wget, detailed above.

Don't worry, this operation actually runs very fast and has a very little impact on the server, equivalent to a normal single page load.

# Setting Up CRON Job in cPanel

To add a new CronJob in cPanel, login to your cPanel and click Cronjobs under the Advanced section as the screenshot below.

To add a new CronJob in cPanel

After clicking Cronjobs, you will be directed to a page similar to the one below. In this example, click Standard to proceed.

After clicking Cronjobs, click Standard to proceed

Enter the following command in the Command to run field on the screen shown below it:

Select Every Five Minutes, Every Hour, Every Day, Every Month, and Every Week Day so that the action above will be executed every five (5) minutes perpetually.

Select Every Five Minutes, Every Hour, Every Day, Every Month, and Every Week Day

# Advanced Algolia Configuration

Algolia provides an extensive configuration to define and optimize the search. The following screenshots are included as a reference of how the Demo site is configured.

# Demo Searchable Fields

Algolia Searchable Fields

# Demo Ranking

Algolia Ranking

# Demo Facets

Algolia Facets

Instant Search

# Demo Instant Search Autocomplete

Instant Search Autocomplete

# Demo Autocomplete Classic

Autocomplete Classic

Last Updated: 4/16/2024, 4:44:17 PM