Is there any documentation anywhere on how to implement full-text search? We've implemented a module that does it and we have it working, but it's rather slow because the generated SQL is not always correct. We are trying to clean up the generated SQL but it seems to be used in more than one database query, and I'm not sure how to guarantee that the SQL includes what we need it to. In some cases, there are subqueries that are generated, and we need the predicate we add to the where clause to match the correlation name, but there's no way to know what that is.
Our modules returns self.extra() with an extra column, an extra table, a join condition, and an order by clause but the join condition is sometimes wrong. When we execute a search, at least three queries are actually executed and for the slowest one, the SQL looks something like:
select count(*) from forum_node
where ...
and forum_node.parent_id in (
select distinct u0.id from forum_node u0, <our table>
where ...
and <our table>.node_id=forum_node.id -- wrong!
...
In this case, we want forum_node.id in the predicate to be u0.id but there are other queries that don't use u0 as the correlation name. Is there a way to modify the query to do the right thing?
asked
21 Mar '11, 09:17
gperrow
246●5●15●23
accept rate:
25%