glFusion Wiki

Site Tools


glfusion:development:api:search:start

Plugin Search Engine Integration

glFusion's search engine provides hooks for plugins to utilize the search engine features.

glFusion's search engine using a 'ranking system' to determine how many search results should be displayed for each component. For example, if all search results were simply returned in date order, there may be 200 results that pre-date a story or an event entry. To provide more relevant search results, each page of the search results contains results from each core service (stories, comments) and each plugin (that supports searching). This provides a much better mix of results.

To determine how many results should be displayed for each search type, glFusion utilizes a ranking algorithm. Each search type is given a rank between 1 and 5, where 5 provides the greatest amount of results. For example, if results are returned for Stories, Forum Posts, and Comments, the following example shows how many results for each would be returned per page.

plugin rank results
stories 5 23
forums 4 18
comments 2 9

With glFusion's search engine, the plugin does not actually perform the search, instead it will return the SQL query to the engine. All SQL queries returned should be without the LIMIT and ORDER BY clauses. The SQL query must have the following column names and look like:

  SELECT id, title, description, date, user, hits, url FROM ... WHERE ...

If a column does not exist in the table then another value should be substituted, for example: '0' AS hits, …

The URL is where to take the user when they have clicked a result. It should start with a single slash if the target is within the current domain. Otherwise the result with be printed, as is, in the href attribute of the link. For example this is the URL statement returned by the Static Pages plugin:

  CONCAT('/staticpages/index.php?page=', sp.sp_id) AS url

Standard SQL Query

  • A string containing a single query.
  • OR An array of two queries for both MSSQL and MySQL DBMS.

All SQL queries returned should be without the LIMIT and ORDER BY clauses. The SQL query must have the following column names and look like:

  SELECT id, title, description, date, user, hits, url FROM ... WHERE ...

If a column does not exist in the table then another value should be substituted, for example: '0' AS hits, …

The url is where to take the user when they have clicked a result. It should start with a single slash if the target is within the current domain. Otherwise the result with be printed, as is, in the href attribute of the link. For example this url belongs to the glFusion site

  CONCAT('/staticpages/index.php?page=', sp.sp_id) AS url

However the Links plugin needs to direct users to external sites when clicked, so providing the url from the database will suffice.

To integrate your plugin into the glFusion search engine, you must define two function in the plugin's function.inc.

  • plugin_searchtypes_{plugin_name}() returns to glFusion the type(s) of search.
  • plugin_dopluginsearch_{plugin_name}() returns the search SQL query back to glFusion.

These functions should be defined in the plugin's function.inc.

Search Integration Functions

glfusion/development/api/search/start.txt · Last modified: 2017/04/12 21:15 (external edit)

Page Tools