One of the things that has bugged me for a while has been the slow search. It was always quicker to search the site via google then to use the search box. I had looked at external systems and never really got far enough to implement any of them. A few days ago while reading the news page I came across an article on Sphinx by James at Mozilla Got Data? Need Search? Use Sphinx. So I gave it a try locally and was pleasantly surprised by the improved speed of search.
The hardest part of the implementation was integrating it with Drupal, there are two sphinx modules available but they both need work before becoming usable in Drupal 6. Other then that set up the index is as simple as writing an sql query, being sure to return a unique id, such as the node id, first then the data to be indexed.
Here's the base query I used for Drupal 6.
sql_query = \ SELECT n.nid, n.title, n.uid, body, changed, t.tid, c.comment \ FROM node n \ INNER JOIN (node_revisions r, term_node t, comments c) \ ON (n.nid = t.nid and r.nid = n.nid and n.nid = c.nid ) \ WHERE n.nid BETWEEN $start AND $end AND n.status = 1 \
The query above includes uid and tid which are added as attributes and used to display facets.
Above the search results you will see the facets, which can be used to refine the search results by author or tags.
There may be a little tweaking required over the next few days to ensure the index is updating correctly. Let me know if you notice any issues.
Author: Tony Aslett