IMHO, search should be capable of returning posts where the search term is either in the title or the body. I'm sure I read somewhere that that is how it worked but I can't be sure.

To reproduce, I added a post with the title PostTitleSearchText and body PostBodySearchText. Searching for the former produces no results while the latter shows correctly.

Comments

acrookes’s picture

In the spirit of this all being open source and me just above the level of coding disaster, I've attempted a fix myself and modified the SQL in the UIEFORM.MODULE/UIEForum_search function as

SELECT t.ThreadID, t.*, p.*, f.* FROM {f_threads} t, {f_posts} p, {f_forums} f WHERE ( LOWER(p.posttitle) LIKE LOWER ('%%%s%%') OR LOWER(p.Content) LIKE LOWER('%%%s%%') ) AND t.ThreadID=p.ThreadID AND f.ForumID=t.ForumID AND f.ForumID IN(1, 2) ORDER BY p.Posted DESC

but this returns no results in Drupal but works fine in phpMyAdmin and any other SQL Editor, albeit after removing the {} and manually entering the search string.

I've also tried using UNION as

SELECT t.ThreadID, t.*, p.*, f.* from {f_threads} t, {f_posts} p, {f_forums} f WHERE LOWER(p.Content) LIKE LOWER('%%%s%%') AND t.ThreadID=p.ThreadID AND f.ForumID=t.ForumID AND f.ForumID IN(1, 2) UNION DISTINCT SELECT t.ThreadID, t.*, p.*, f.* from {f_threads} t, {f_posts} p, {f_forums} f WHERE LOWER(p.posttitle) LIKE LOWER('%%%s%%') AND t.ThreadID=p.ThreadID AND f.ForumID=t.ForumID AND f.ForumID IN(1, 2) ORDER BY Posted DESC

Like the first example, this does work in an SQL editor after being cleaned. However, in Drupal, it returns all posts as if the where clause is being ignored.

I'm sure I am doing something wrong - Does anyone have any ideas?

daniel.hunt’s picture

This is what I would do in this case:

SELECT t.ThreadID, t.*, p.*, f.* FROM {f_threads} t, {f_posts} p, {f_forums} f WHERE (LOWER(p.Content) LIKE LOWER('%%%s%%') OR LOWER(p.PostTitle) LIKE LOWER('%%%s%%')) AND t.ThreadID=p.ThreadID AND f.ForumID=t.ForumID

The SQL is much cleaner this way, and the rest of the query is unaffected. If this works as you would expect, (I'm sure it will), let me know and I'll include it in the main release.

daniel.hunt’s picture

Assigned: Unassigned » daniel.hunt
Status: Active » Fixed

That's not the only bug actually. I'm committed the new version of the module that includes post titles in the searching, thanks for your help in fixing it!

It should be ready for download from about midday. (GMT I believe)
Daniel

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.