Skip to content

Commit

Permalink
fix fulltext search
Browse files Browse the repository at this point in the history
  • Loading branch information
skywalker512 committed Jun 17, 2018
1 parent b3f09de commit 9ff41da
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion core/models/ETSearchModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,32 @@ public function getConversationIDs($channelIDs = array(), $searchString = "", $o

// Run a query against the posts table to get matching conversation IDs.
$fulltextString = implode(" ", $this->fulltext);
$fulltextQuery = ET::SQL()
if(preg_match('/[\x80-\xff]/i',$fulltextString))
{

$fulltextQuery = ET::SQL()
->select("DISTINCT conversationId")
->from("post")
->where("(title LIKE :fulltext) OR (content LIKE :fulltext)")
->where($idCondition)
->orderBy("conversationId DESC")
->bind(":fulltext", "%".$fulltextString."%")
->bind(":fulltextOrder", $fulltextString);



}
else
{
$fulltextQuery = ET::SQL()
->select("DISTINCT conversationId")
->from("post")
->where("MATCH (title, content) AGAINST (:fulltext IN BOOLEAN MODE)")
->where($idCondition)
->orderBy("MATCH (title, content) AGAINST (:fulltextOrder) DESC")
->bind(":fulltext", $fulltextString)
->bind(":fulltextOrder", $fulltextString);
}

$this->trigger("fulltext", array($fulltextQuery, $this->fulltext));

Expand Down

0 comments on commit 9ff41da

Please sign in to comment.