Hello all,
For those that may not know me, my name is Sami and I'm one of the Google Summer of Code lot. I am working on improving the search pages for Geeklog. Unfortunately I had a late start on coding due to exams, and as this was my last year at University I was especially busy

. So I really made a start on things earlier last week.
I plan to start off by revamping the results page. This will be done by placing all the results into a single table that has fixed headings. I will then work on improving the query times on large databases and also making the most relevant results appear first. So hopefully when a search is performed the user will be presented with a simple results table and the result they want so that they can quickly navigate to the relevant page. Once this is done, Ajax will be used to allow users to reorder the results and move though pages without having to reload the entire page. Then as an extra feature a tag cloud will be implemented.
So I have broken down the project into three tasks:
- Place all the results into a single table, with the most relevant results first.
- Increase the responsiveness of the page by optimizing the SQL query times and using Ajax.
- Implement a tag cloud.
In the future I will post up more details on how I plan to carry out each task, but for now I just want to focus on the first task.
Single Results Table
At the moment when a search is conducted each plugin returns an instance of the Plugin() class which contains the heading names and some results, which are based on the number of results to show per page and the page number. To combine all the results into a single table was relatively simple, just don't print the bits between each table (the table title and heading). The tricky part was finding similarities in the headings so that the right details appear under the correct heading.
Progress: Done!!
Click here to view a screen shot.
Plugin Search API
The API in the new system will work by having plugins return a search query. Once all the queries are returned they will be appended to each other using UNION ALL, then ordering and the limits will be added. So essentially there is only one query that's executed, which will look something like this:
(SELECT id, hits ... FROM ... WHERE ...) UNION ALL (plugin2_query) UNION ALL (plugin3_query) ORDER BY hits LIMIT 0, 10;
By using UNION all the queries _MUST_ have the same column names, so the SELECT part needs to have the following headings: id, nice_name, plugin_name, title, description, date, user, hits, url.
Here is an example of the select statement for the Stories:
Text Formatted Code
$select = "SELECT
s.sid AS id, // Used for the expandable results
'Story' AS nice_name, // Used in the Category column
'story' AS plugin_name, // Used for the expandable results
s.title AS title, // The title of the item
'Desc' AS description, // Short description
UNIX_TIMESTAMP(s.date) AS date, // the date of the item
s.uid AS user, // The user id
s.hits AS hits, // Views, Downloads, the popularity of the item
CONCAT('/article.php?story=',s.sid) AS url"; // When the user clicks on a link
These heading and the structure may be subject to change, this is just what I have working at the moment.
My idea for the description column is to have a short description of the item centred around the search term, for example if the search term is 'geeklog' then the text that appears in the column may be '...release candidate for geeklog 1.5.0 is now...' with the word 'geeklog' highlighted.
I am particularly interested to hear what plugin developers think about this API compared to the previous one. It should be fairly easy to upgrade plugins as a query is already being used, they just have to return it instead of processing it. The only problems that I foresee is when a plugin does not have a record for how many hits an item has such as FAQ or the Calendar. In these cases the plugin will have to return the value 0.
Progress: Its been implemented, the column heading are not fixed yet and are subject to change.
Ordering the Results
By clicking the column heading will allow the user to sort each column in ascending or descending order. By default the results will be ordered by the 'hits' column, this will allow the most popular result to appear first. But to allow the results table to be fair amongst all plugins the results will work on a ratio basis, where each plugin will have a rank. Some plugins have less of a place in the results table where are others should dominate the table. For example users often want to search for forum posts or stories but are less likely to want to find anything in the comments sections. So by applying a rank to each plugin they will return a varying number of results. The ranks will be from lower priority, 1, to higher priority, 5. Below is an example of a Geeklog system with 3 plugins and a results page that displays a total of 50 results.
Text Formatted Code
plugin rank results
---------------------------
stories 5 23
forums 4 18
comments 2 9
Progress: This part of the project is still in its infancy, and so far has not been implemented.
Expandable Information
As some plugins have a need to return more information but now cant due to the fixed table headings... fret not there is still hope! Each row will be made to expand to show more information on that result. This will need an extra function added to the search API, plugin_searchdetail_{my plugin}. The function should return more details on a search result it will be passed a single 'id' that will identify the result. I have a feeling that to start off with the extra details may just be a full story, comment or forum post. But this will allow plugins to have a place in the search page and hopefully some people can experiment with returning different types of details.
Progress: Its been implemented but still needs a lot more work and testing. Click here for a screen shot.
Backwards Compatibility
This has already been briefly discussed in merging the tables into one, but lets recap. Plugins that use the old system will still work, they may not be as affective in the new system but hopefully the plugin developers can make updates to accommodate these changes. Similarities will be drawn from the returned Plugin() instance so that the information appears under the correct heading. When a user expands a row of a result that is using the old system then a simple message will be displayed, some thing like 'No further details available...sorry!' The awkward part is merging the result set from the old system with the new and sorting them. The way its working at the moment is by executing the query and storing the result in an array, that array is then merged with the results from plugins using the old system and sorted programmicly. Ideally when all the available plugins are using the new system there should be huge improvements.
Progress: Complete...I think, needs testing.
Updating Plugins
The new search system would be a bit useless if the core plugins didn't support it. So I will be updating the main plugins, so far I have been working with the Stories and Comments. My main aim at the moment is completing the other parts of this project. Once they are done I will look into updating the plugins that come with GL such as Static Pages, Calendar and Links. I will be here also to support the plugins developers should they have any questions or requests.
Progress: Stories and Comments pretty much done. Static Pages, Calendar and Links still to do.