Can you perhaps give an example of what you have, and of what you want ?
If I understand correctly, you just want a way to order your results on relevancy.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Is it not possible to do an OR search with your query, let that calculate the weight in the result for each keyword, and then group it by article and summing the weight. Then you can order by the summed weight descending, without having to run X queries.
What I know from weighted keywords, is that it is not always true that having all keywords will outrank any other (depending on your weighting system).
Could you show me the query for a search on a single table ?
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
You should be able to do an OR search, and then GROUP BY link_id and SUM(weight).
SELECT link_id, SUM(weight) AS weight, domain
FROM yourtables
WHERE your keywords filter with OR instead of AND
GROUP BY link_id
Perhaps you can try it in PhpMyAdmin (or another tool you use), to see if it gets results. Anything you can move from code to query, will speed things up.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
You get that because link_id appears in more tables. So in the SELECT and GROUP BY you need to specify which one you mean, just like you did with keyword_id in the WHERE.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Not sure what you mean. The GROUP BY will merge the results to one link_id, just as your DISTINCT did earlier, but it will SUM all the weights for that link_id.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Put the tablename and a dot in front of it.
link_keyword3.link_id for example.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Pooh, this is getting difficult to do from the top of my head now. I don't think the WHERE should contain a SELECT like that.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
I could use some example data with that, just a small example of what you have (5 records or so). Then I will try tonight.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875