private function setParamsByContent(WP_Post $post)
 {
     $this->fields = ["post_title", "post_content"];
     $this->min_term_freq = 4;
     $this->minimum_should_match = '60%';
     $this->max_query_terms = 25;
     $stop_words = new StopWords();
     $this->search_query = $stop_words->stripStopWords($post->title . ' ' . $post->post_content);
 }
Example #2
0
 function indexDocument($sDocument, $sUrl)
 {
     $aKeyWords = preg_split('/(<\\s*p\\s*\\/?>)|(<\\s*br\\s*\\/?>)|[\\s,\\-\\/]/i', $sDocument);
     foreach ($aKeyWords as $nOffset => $sKeyWord) {
         $sKeyWord = preg_replace('/[^a-z0-9\']+/', '', strtolower($sKeyWord));
         if (strlen($sKeyWord) > 0 && !StopWords::bStopWord($sKeyWord)) {
             try {
                 $oStmtWords->execute(array($sKeyWord));
             } catch (Exception $e) {
                 $oStmtWordsUpdate->execute(array($sKeyWord));
             }
             $oStmtStems->execute(array(PorterStemmer::Stem($sKeyWord), $sUrl, $nOffset));
         }
     }
 }