You probably already know Joomla has built-in search functionality, which meets modern requirements - the smart search component. But what if your users need a little more? What if you want third party extensions to be searchable as well? In this series of articles, we will look at how to create a smart search plugin for a third-party Joomla component.
Historically, there were 2 search components in the Joomla core: just "search" and "smart search". A simple search was included in Joomla 1.x and has not changed significantly since then. In order for this component (com_search) to search not only in the core components, it was necessary to write a plugin, the essence of which was mainly to give the component the necessary SQL query and form an object of a structure understandable to the component from the query results. The search itself was essentially an SQL query to the database with LIKE '%word%'. There have also been cases when the Sphinx search engine in Joomla was used with the help of a simple search plugin.
Indexing content with smart search in Joomla 5
Starting with Joomla 2.5, the Smart search component, com_finder, was included in the core, the main difference between which and simple search was content indexing. The search itself began to produce results based on the relevance of the content. For the site user, search parameters have appeared that allow you to limit the results using filters based on various parameters: the start and end date of publication, language, type (article, category, product, etc.), specific category, author. Under the hood, the text is divided into tokens, weight is calculated for tokens, etc. Indexing settings are available in the component settings.
An example from the Joomla smart search hint for site visitors:
Entering this and that into the search form will return results containing both "this" and "that".
Entering this not that into the search form will return results containing "this" and not "that".
Entering this or that into the search form will return results containing either "this" or "that".
Entering "this and that" (with quotes) into the search form will return results containing the exact phrase "this and that".
I would like to note once again that this is the functionality of the Joomla core, not a third-party extension and not some kind of third-party, usually paid, service.
In practice, I have come across the fact that site visitors usually do not use all these additional filters and search parameters, but rather ask again to clarify the query. On a regular site with articles, search parameters are unlikely to be in demand, but in an internal closed help system or documentation system (Joomla has versioning of articles and Workflows, see details on docs.joomla.org) these parameters would be more in demand.
Updating the index (reindexing)
The index of your mini-google needs to be updated periodically, since something is constantly changing on the live site: products and articles are added, archived, deleted, contacts are updated, etc. In order for the user to receive up-to-date data in the search, you need to regularly reindex the content. The index results are stored in the database, which is why it increases in size. This is normal for this search implementation.
You can start indexing manually from the admin panel
Or (this is the preferred option) using the Joomla CLI server command line. To do this, go to the cli folder of your site (how to work with Joomla CLI for more information, see the article Joomla 4: A Powerful CLI Application).
CLI folder in Joomla.
In this folder, run the command:
php joomla.php finder:index
And Joomla indexes your content pretty quickly.
Indexing by smart search in Joomla 5 via the CLI.
We add this command to CRON for scheduled execution and site visitors will be happy to see the current search results.
0 2 * * * php /path/to/site/public_html/cli/joomla.php finder:index >/dev/null 2>&l
Indexing custom fields in Joomla
Joomla user fields are used for a wide variety of types of sites, often for catalogs of services or goods where online payment and calculation of delivery on the site are not required. In order for Joomla to search by the values of these fields, you need to specify the "Search Index" parameter for each field (the "Options" tab, at the very bottom):
You can also see the article Adding custom fields in the results of Smart Search and JFilters, which describes how to display field values in search results using layout override.
A taxonomy is a way to display field data in search results, for example, "Category: Any category", "Author: Any author." The taxonomy can be nested. To search by field value, select the "Make searchable" or "Make searchable and add as taxonomy" options.
A taxonomy example in Joomla smart search.
In the next article, we will look at how to create a smart search plugin for a Joomla component using the example of JoomShopping. We will start to encounter nuances and details that could hinder us, but in the end we will overcome all difficulties and create a working smart search plugin for Joomla 5.
Joomla Community resources
- https://joomla.org/
- This article in Joomla Community Magazine
The above is the detailed content of The anatomy of smart search in Joomla art Introduction.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ToversionaPHP-basedAPIeffectively,useURL-basedversioningforclarityandeaseofrouting,separateversionedcodetoavoidconflicts,deprecateoldversionswithclearcommunication,andconsidercustomheadersonlywhennecessary.StartbyplacingtheversionintheURL(e.g.,/api/v

TosecurelyhandleauthenticationandauthorizationinPHP,followthesesteps:1.Alwayshashpasswordswithpassword_hash()andverifyusingpassword_verify(),usepreparedstatementstopreventSQLinjection,andstoreuserdatain$_SESSIONafterlogin.2.Implementrole-basedaccessc

Proceduralandobject-orientedprogramming(OOP)inPHPdiffersignificantlyinstructure,reusability,anddatahandling.1.Proceduralprogrammingusesfunctionsorganizedsequentially,suitableforsmallscripts.2.OOPorganizescodeintoclassesandobjects,modelingreal-worlden

PHPdoesnothaveabuilt-inWeakMapbutoffersWeakReferenceforsimilarfunctionality.1.WeakReferenceallowsholdingreferenceswithoutpreventinggarbagecollection.2.Itisusefulforcaching,eventlisteners,andmetadatawithoutaffectingobjectlifecycles.3.YoucansimulateaWe

To safely handle file uploads in PHP, the core is to verify file types, rename files, and restrict permissions. 1. Use finfo_file() to check the real MIME type, and only specific types such as image/jpeg are allowed; 2. Use uniqid() to generate random file names and store them in non-Web root directory; 3. Limit file size through php.ini and HTML forms, and set directory permissions to 0755; 4. Use ClamAV to scan malware to enhance security. These steps effectively prevent security vulnerabilities and ensure that the file upload process is safe and reliable.

In PHP, the main difference between == and == is the strictness of type checking. ==Type conversion will be performed before comparison, for example, 5=="5" returns true, and ===Request that the value and type are the same before true will be returned, for example, 5==="5" returns false. In usage scenarios, === is more secure and should be used first, and == is only used when type conversion is required.

Yes, PHP can interact with NoSQL databases like MongoDB and Redis through specific extensions or libraries. First, use the MongoDBPHP driver (installed through PECL or Composer) to create client instances and operate databases and collections, supporting insertion, query, aggregation and other operations; second, use the Predis library or phpredis extension to connect to Redis, perform key-value settings and acquisitions, and recommend phpredis for high-performance scenarios, while Predis is convenient for rapid deployment; both are suitable for production environments and are well-documented.

The methods of using basic mathematical operations in PHP are as follows: 1. Addition signs support integers and floating-point numbers, and can also be used for variables. String numbers will be automatically converted but not recommended to dependencies; 2. Subtraction signs use - signs, variables are the same, and type conversion is also applicable; 3. Multiplication signs use * signs, which are suitable for numbers and similar strings; 4. Division uses / signs, which need to avoid dividing by zero, and note that the result may be floating-point numbers; 5. Taking the modulus signs can be used to judge odd and even numbers, and when processing negative numbers, the remainder signs are consistent with the dividend. The key to using these operators correctly is to ensure that the data types are clear and the boundary situation is handled well.
