Smart Search plug-ins are gathered together for convenience into a plug-in group called "finder". Take a look in the plugins/finder directory and you will see the plug-ins that support the core Joomla content types. It is best to create your own plug-in by taking a copy of one of these plug-ins and adapting it to meet your specific needs.

All Smart Search plug-ins extend the FinderIndexerAdapter class which contains a good many methods to deal with maintaining the index. For the vast majority of custom content requirements you will only need to override a few of these methods.

There is some additional information on writing a Smart Search plug-in here.

[edit] The principal properties

Before looking at the methods, there are a few properties that need to be set up correctly:

[edit] The principal methods

The first methods you will want to override when developing a new Smart Search plug-in are the setup, index and getListQuery methods. In the vast majority of cases those three methods will be enough to get your content indexed, although the plug-in will not be complete as there are other methods that must be implemented to deal with issues such as updating the index when the content changes. But those three methods are the working core of the plug-in.

[edit] Some other methods

For a complete Smart Search plug-in there are a number of other methods you may need to override.

[edit] Event methods

The following methods are called via the Smart Search content plug-in in response to specific trigger events in Joomla.

[edit] Methods in more details

[edit] getListQuery

This method must return a JDatabaseQuery object that will form the basis of a query that will return a list of objects of the given content type. There are constraints on this query to ensure that it is compatible with other methods used by the indexer. If the following conditions are not true then you will need to override other methods in the FinderIndexerAdapter class.

[edit] index

This method is called whenever a content item needs to be indexed (or re-indexed). It is passed an object of type FinderIndexerResult and its purpose is to make adjustments to that object and to add metadata before handing control to FinderIndexer::index method to do the indexing proper.

[edit] setup

This method is called prior to the index method and is used to set up the index process. In this method is where you would typically include any externally required classes to allow for proper indexing.

[edit] FinderIndexerResult properties

[edit] Testing

Testing a finder plugin can be a bit difficult due to the fact that it is typically run using an ajax process, so you don't tend to actually see any results from the process.

As such, one way to test is to use the command line indexer.[2]

Open a command prompt/ssh session on the server and go to the root directory of the website. From there, you can run the indexer and errors and log messages will go to the screen.

php cli/finder_indexer.php

[edit] Notes

  1. If this condition is not true you will also have to override the getItem, getUpdateQueryByTime and getUpdateQueryByIds methods
  2. Setting up automatic Smart Search Indexing
License: Joomla! Electronic Documentation License
Source page: http://docs.joomla.org/Creating_a_Smart_Search_plug-in
Page retrieved: 0.268 seconds, 2.19 MB

Top