Forums: How to use full text search in PHPRunner applications - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to use full text search in PHPRunner applications

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16109
  • Joined: 03-February 03
  • Gender:Male

Posted 05 December 2018 - 04:40 AM

PHPRunner doesn't have built-in capabilities to use SQL Server Full Text search but it is fairly easy to implement. Lets assume we have three large text or binary fields Attachment1, Attachment2 and Attachment3 that are setup as full text search fields in SQL Server. We also assume that you use basic all fields type of search.

Here is the code you need to add to AfterTableInit event in order to enable full text search on those three fields:

$srchObj = SearchClause::getSearchObject($table);
$s = $srchObj->getAllFieldsSearchValue();
if ($s!="") {
$where = sprintf("contains(Attachment1, '%s') or contains(Attachment2, '%s') or contains(Attachment3, '%s')", $s, $s, $s);
$query->addWhere( $where );
}


And the same kind of code for MySQL:

$srchObj = SearchClause::getSearchObject($table);
$s = $srchObj->getAllFieldsSearchValue();
if ($s!="") {
$where = sprintf("MATCH(Attachment1, Attachment2, Attachment3) AGAINST('%s' IN NATURAL LANGUAGE MODE)", $s);
$query->addWhere( $where );
}

Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users