sphinx\Query $snippetCallback

$snippetCallback public property

PHP callback, which should be used to fetch source data for the snippets. Such callback will receive array of query result rows as an argument and must return the array of snippet source strings in the order, which match one of incoming rows. For example:

$query = new Query();
$query->from('idx_item')
    ->match('pencil')
    ->snippetCallback(function ($rows) {
        $result = [];
        foreach ($rows as $row) {
            $result[] = file_get_contents('/path/to/index/files/' . $row['id'] . '.txt');
        }
        return $result;
    })
    ->all();
doc_Yii
2016-10-30 17:12:14
Comments
Leave a Comment

Please login to continue.