Jump to content

MySQL keyword frequency


jaoudestudios

Recommended Posts

Hi,

 

I hope someone can help.

 

I am doing a mysql search on 3 columns within a table, and I am ranking the returned result and ordering by the total relevance. However, I would like to add another count to the relevance if the keyword appears in the field more than once.

 

Below is a simplified version.

SELECT *, (

(CASE WHEN title LIKE '%the%' THEN 2 ELSE 0 END) +

(CASE WHEN content LIKE '%the%' THEN 1 ELSE 0 END)

) as relevance

FROM content WHERE (page LIKE '%the%' OR title LIKE '%the%' OR content LIKE '%the%')

ORDER BY relevance DESC

 

So if 'the' appears in the 'title' column and 'content' column the result will be 3. But if 'the' appears three times in the 'content' column it won't total 3 and then add it to the 2 from 'title' to equal 5. But I would like it to total 5.

 

Hope that makes sense.

Thanks,

Eddie

Link to comment
https://forums.phpfreaks.com/topic/111818-mysql-keyword-frequency/
Share on other sites

I have created a simple stored procedure and I can get it to work on the command line, but I can not get it to work through php 5.

 

I have read many examples on how to call the stored procedure through php, but how do I set it? on the command line I use 'SOURCE procedure_file.sql' and it is ready to be called.

 

Please can you show me how to call the source file in php?

how would I do that? through the sql textarea?

 

I would need to load the external script (procedure) and then call it.

 

Can I send the script in a query instead of loading it from a *.sql file.

Well, you only need to "load" it once... and since the stuff in the .sql file is SQL statements, yes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.