Home  >  Article  >  Backend Development  >  I encountered a problem during the first trial of laravel-search, please help!

I encountered a problem during the first trial of laravel-search, please help!

WBOY
WBOYOriginal
2016-07-06 13:51:57852browse

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,
I encountered a problem during the first trial of laravel-search, please help!
My skill is low, please give me some advice, thank you! ! !

Reply content:

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,
I encountered a problem during the first trial of laravel-search, please help!
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?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn