$count) { if (isset($wordtoid[$word])) $contentwordidcounts[$wordtoid[$word]] = $count; } qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $contentwordidcounts); // Add to tag words index $tagwordids = qa_array_filter_by_keys($wordtoid, $tagwords); qa_db_tagwords_add_post_wordids($postid, $tagwordids); // Add to whole tags index $wholetagids = qa_array_filter_by_keys($wordtoid, $wholetags); qa_db_posttags_add_post_wordids($postid, $wholetagids); // Update counts cached in database (will be skipped if qa_suspend_update_counts() was called qa_db_word_titlecount_update($titlewordids); qa_db_word_contentcount_update(array_keys($contentwordidcounts)); qa_db_word_tagwordcount_update($tagwordids); qa_db_word_tagcount_update($wholetagids); } public function unindex_post($postid) { require_once QA_INCLUDE_DIR . 'db/post-update.php'; $titlewordids = qa_db_titlewords_get_post_wordids($postid); qa_db_titlewords_delete_post($postid); qa_db_word_titlecount_update($titlewordids); $contentwordids = qa_db_contentwords_get_post_wordids($postid); qa_db_contentwords_delete_post($postid); qa_db_word_contentcount_update($contentwordids); $tagwordids = qa_db_tagwords_get_post_wordids($postid); qa_db_tagwords_delete_post($postid); qa_db_word_tagwordcount_update($tagwordids); $wholetagids = qa_db_posttags_get_post_wordids($postid); qa_db_posttags_delete_post($postid); qa_db_word_tagcount_update($wholetagids); } public function move_post($postid, $categoryid) { // for now, the built-in search engine ignores categories } public function index_page($pageid, $request, $title, $content, $format, $text) { // for now, the built-in search engine ignores custom pages } public function unindex_page($pageid) { // for now, the built-in search engine ignores custom pages } public function process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent) { require_once QA_INCLUDE_DIR . 'db/selects.php'; require_once QA_INCLUDE_DIR . 'util/string.php'; $words = qa_string_to_words($query); $questions = qa_db_select_with_pending( qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($query), $start, $fullcontent, $count) ); $results = array(); foreach ($questions as $question) { qa_search_set_max_match($question, $type, $postid); // to link straight to best part $results[] = array( 'question' => $question, 'match_type' => $type, 'match_postid' => $postid, ); } return $results; } }