Closed (fixed)
Project:
SQL Search (Trip Search)
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 May 2005 at 18:53 UTC
Updated:
11 Oct 2005 at 21:00 UTC
comments are excluded from search results ATM
Comments
Comment #1
nedjoI tried the following code to include comments in the general node search, but commented it out as it led to no results being returned. The code adds
c.subjectandc.commentto the list of fields being selected and creates a join between thecommentsandnodefields. Any suggestions as to why this doesn't work?Comment #2
kbahey commentedNedjo
I also noticed this comment in function node_trip_search()
// When comments are included, no results are returned. What is the problem?
// if (module_exist('comment')) {
// $query->fields[] = 'c.subject';
// $query->fields[] = 'c.comment';
// $query->joins .= ' INNER JOIN {comments} c ON n.nid = c.nid';
// }
I think the reason is that this is an INNER JOIN. So it tries to join nodes to comments, and since not all nodes have comments, this does not work.
Try a LEFT JOIN instead and see if it works.
Comment #3
nedjoYep, thanks kblahey, that worked.
Comment #4
(not verified) commentedComment #5
(not verified) commentedComment #6
(not verified) commentedComment #7
(not verified) commentedComment #8
(not verified) commentedComment #9
(not verified) commentedComment #10
(not verified) commentedComment #11
(not verified) commentedComment #12
(not verified) commented