2.8.1.6. Sphinx test

To check the functionality of Sphinx, set the default configuration and run the script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$search_string = '';
$index_name = 'test_index';

$link = mysqli_init();
mysqli_real_connect($link, null, null, null, null, null, '/home/' . get_current_user() . '/.system/sphinx/sphinx-mysql.socket');

$result = mysqli_query($link, "select id from $index_name where match('$search_string')");
while($row = mysqli_fetch_assoc($result)) {
    echo $row['id'] . PHP_EOL;
}

If Sphinx is running, the script will display lines containing numbers.

Content