Thursday, April 13, 2017

laravel, using sngrl sphinx, can't get all indexes created on server

I am using laravel, and sphinx as searching engine. I configured everything on both sides but i can't get all indexes.

my sphinx.conf is as this links : http://prnt.sc/ew0dhn and http://prnt.sc/ew0dr8 and the connection to the bd on top.

When i go to the laravel i have this sphinxsearch.php file:

<?php
return array(
    'host'    => '127.0.0.1',
    'port'    => 9312,
    'timeout' => 30,
    'indexes' => array(
        'users' => array('table' => 'users', 'column' => 'id'),
        'roles' => array('table' => 'roles', 'column' => 'id'),               
        'agencia' => array('table' => 'agencia', 'column' => 'id'),
    ),
    'mysql_server' => array(
        'host' => '127.0.0.1',
        'port' => 9306
    )
);

For indexes "users" and "roles" this configuration works, but for "agencias" don't and i don't know why.

     $sphinx = new SphinxSearch();
//dd($sphinx);

        $agencias =  $sphinx->search('', 'agencias') ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED2)->get();
//dd($agencias);

        foreach ($agencias as $agencia ) {
            $agenciasID[$agencia->id] = $agencia->id;
        }        

       $usersArray = $sphinx->search('', 'users') ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED2)->filter('agencia_id', array(2))->get();

I tried to create another indexes based on same source (sphinx.conf), but that new indexes didn't work too.

The Error i got on the page is: Undexfined index: agencias on SphinxSearch.php line 203.

What am i doing wrong?



via António Gonçalves

Advertisement