This topic is locked

How to use full text search in PHPRunner applications

12/4/2018 11:40:37 PM
PHPRunner Tips and Tricks
admin

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 );

}