FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » searching for substrings in words in message-search
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: searching for substrings in words in message-search [message #159405 is a reply to message #159383] Sun, 31 May 2009 09:58 Go to previous message
Peter Vendike is currently offline  Peter Vendike   Denmark
Messages: 65
Registered: February 2009
Location: Denmark
Karma:
Member
Translator
Got it to work like this:

(Concatanation in Mysql works, couldn't get php to make the concat right)



-		q("INSERT IGNORE INTO {SQL_TABLE_PREFIX}search_cache (srch_query, query_type, expiry, msg_id, n_match) SELECT '".$qry_lck."', ".$qt.", ".__request_timestamp__.", msg_id, count(*) as word_count FROM {SQL_TABLE_PREFIX}search s INNER JOIN {SQL_TABLE_PREFIX}".$tbl." i ON i.word_id=s.id WHERE word IN(".$qr.") GROUP BY msg_id ORDER BY word_count DESC LIMIT 500");

+		q("CREATE TEMPORARY TABLE si (idsi int, id int(11), word varchar(50), word_id int(11), msg_id int(11))");
+		foreach($wa as $w) {
+			q("INSERT INTO si SELECT * FROM {SQL_TABLE_PREFIX}search s INNER JOIN {SQL_TABLE_PREFIX}".$tbl." i ON i.word_id=s.id WHERE word LIKE CONCAT(".$w.", '%')");
+			}
+		q("INSERT IGNORE INTO {SQL_TABLE_PREFIX}search_cache (srch_query, query_type, expiry, msg_id, n_match) SELECT '".$qry_lck."', ".$qt.", ".__request_timestamp__.", msg_id, count(*) as word_count FROM si GROUP BY msg_id ORDER BY word_count DESC LIMIT 500");



Next thing could be to make it selectable, wich type of search you want.


Peter
[Message index]
 
Read Message
Read Message
Previous Topic: Hacks for files in /src directory must get compiled before run!
Next Topic: custom tags display area and forum rank
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 07:18:47 GMT 2024

Total time taken to generate the page: 0.04961 seconds