You are here: C97net • 5.11 Misc Functions
A faster method to search for any items in database
Fast Search (FS) is a search alternative for traditional SQL search (SELECT * FROM table WHERE body LIKE '%keywords%'). FS offers much faster search result, up to 20x faster (or more, on large database).
To use this function please follow the steps:
1. Determine an identifier, eg. 'product'.
2. Get word list. Word list is an array listing all uniquely used words in an article.
$wl = filter_word ($input_text);
3. Then use update_wordmatch() function to enter the word list to database.
$fs = update_wordmatch ($article_id, $identifier, $word_list)
$article_id is the unique ID of the article, it can be page ID, news ID, or any ID. It must be integer.
$identifier = the identifier, eg 'product'
$word_list = the word list result from filter_word () function.
4. Be aware that, both filter_word & update_wordmatch functions only available in ACP (or by including includes/admin_func.php).
5. After that, you can use fast_search to search:
$foo = function fast_search ($query, $identifier, $mode = 'or')
$query = the query, eg. "My Book".
$identifier = the pre-defined identifier.
$mode = either 'AND' or 'OR'.
EG:
$foo = function fast_search ('My Book', 'product')
It will return array of $article_id relating with the search result.
Example 1
(coming soon)
There is no comment. Why not be the first?