Home > Article > Backend Development > I encountered a problem during the first trial of laravel-search, please help!
According to http://laravelacademy.org/post/3781.html to install Elasticsearch (after startup, test the normal return information through curl -X GET http://localhost:9200) and mmanos/laravel-search dependencies accordingly. It explains the configuration and finally wrote the calling program. The program is as follows
<code><?php namespace App\Http\Controllers\Search; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Mmanos\Search\Search; class Esearch extends Controller { protected $search; public function __construct(Search $search) { $this->search = $search; } public function insert(){ $this->search->insert( "post-1", array( 'title' => 'My title', 'content' => 'The quick brown fox...', 'status' => 'published', ), array( 'created_at' => time(), 'creator_id' => 5, ) ); } public function res(){ $results = Search::search('content', 'fox')->get(); var_dump($results); } }</code>
The access result is as follows, and the error is as follows,
My skill is low, please give me some advice, thank you! ! !
According to http://laravelacademy.org/post/3781.html to install Elasticsearch (after startup, test the normal return information through curl -X GET http://localhost:9200) and mmanos/laravel-search dependencies accordingly. The instructions are configured, and finally the calling program is written. The program is as follows
<code><?php namespace App\Http\Controllers\Search; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Mmanos\Search\Search; class Esearch extends Controller { protected $search; public function __construct(Search $search) { $this->search = $search; } public function insert(){ $this->search->insert( "post-1", array( 'title' => 'My title', 'content' => 'The quick brown fox...', 'status' => 'published', ), array( 'created_at' => time(), 'creator_id' => 5, ) ); } public function res(){ $results = Search::search('content', 'fox')->get(); var_dump($results); } }</code>
The access result is as follows, the error is as follows,
My skill is low, please give me some advice, thank you! ! !
Look at the comments below, it’s the first one right now.
The academy gentleman’s reply is:
Have you installed the elasticsearch dependent components?