Sainath Krishnan
Sainath Krishnan

Reputation: 2139

Using sphinxsearch with Laravel

I'm trying to get SphinxSearch to work with Laravel. I've installed it according to instructions given here. However, I can't get the querying to work, and I can't find any working examples available online either.

This is what I am trying - (Note : the given email exists in the table)

$results = SphinxSearch::search('[email protected]','testindex')->get();

dd($results);

I also tried it with the query itself instead of a 'search term' -

$results = SphinxSearch::search('select * from user_directory where Email like [email protected]','testindex')->get();

dd($results);

This is my config file-

return array (
    'host'    => '127.0.0.1',
    'port'    => 9312,
    'indexes' => array (
        'testindex' => array ( 'table' => 'user_directory', 'column' => 'Email' ),
    )
);

Upon running my server and loading the page, $results contains only boolean False. Am I wrong in the way I am executing my search?

Note : I am running my test server using Artisan's serve, which runs on port 8000, does that matter here?

Edit : Been working on this for a very long time now with no avail. I've followed the code in the sphinxsearch.php file line by line, still unable to determine why the query returns null! Any help is immensely appreciated

E̶d̶i̶t̶ ̶2̶ ̶:̶ ̶I̶s̶ ̶a̶d̶d̶i̶n̶g̶ ̶t̶h̶e̶ ̶d̶e̶p̶e̶n̶d̶e̶n̶c̶y̶ ̶t̶o̶ ̶̶c̶o̶m̶p̶o̶s̶e̶r̶.̶j̶s̶o̶n̶̶ ̶a̶n̶d̶ ̶r̶u̶n̶n̶i̶n̶g̶ ̶a̶n̶ ̶̶u̶p̶d̶a̶t̶e̶̶ ̶e̶n̶o̶u̶g̶h̶ ̶t̶o̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶S̶p̶h̶i̶n̶x̶?̶ ̶O̶r̶ ̶d̶o̶ ̶I̶ ̶n̶e̶e̶d̶ ̶t̶o̶ ̶*̶*̶m̶a̶n̶u̶a̶l̶l̶y̶*̶*̶ ̶d̶o̶w̶n̶l̶o̶a̶d̶ ̶i̶t̶ ̶f̶r̶o̶m̶ ̶[̶h̶e̶r̶e̶]̶[̶2̶]̶ ̶a̶n̶d̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶i̶t̶ ̶a̶s̶ ̶w̶e̶l̶l̶?̶

Edit 3 : Installed the gigablah/sphinxphp dependency (My mistake, did not know about this as I didn't pay attention to composer's error message before). Still does not work unfortunately!

Edit 4 : Sphinx for windows installed and fully configured and indexed... Still not working.

Upvotes: 2

Views: 3759

Answers (2)

Renie
Renie

Reputation: 60

What do you get when you try this?

    $results = SphinxSearch::search('term','index')->get();

dd($results);

Upvotes: 2

barryhunter
barryhunter

Reputation: 21091

Looking at https://github.com/scalia/sphinxsearch/blob/master/src/Scalia/SphinxSearch/SphinxSearch.php

notice the get() function, never actully checks the error returned from the sphinxAPI.

getLastError should be used in case of failures, to find out what happened.

There is a getErrorMessage function so try calling that.

Upvotes: 0

Related Questions