首頁  >  文章  >  後端開發  >  laravel-search初试遇见的问题,求助!

laravel-search初试遇见的问题,求助!

WBOY
WBOY原創
2016-07-06 13:51:57853瀏覽

按http://laravelacademy.org/post/3781.html 安装了Elasticsearch(启动后通过curl -X GET http://localhost:9200 测试正常返回信息) 及mmanos/laravel-search依赖 也相应按说明做了配置,最后写了调用程序,程序如下

<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>

访问结果如下错误,
laravel-search初试遇见的问题,求助!
小弟水平低,请指点,谢谢!!!

回复内容:

按http://laravelacademy.org/post/3781.html 安装了Elasticsearch(启动后通过curl -X GET http://localhost:9200 测试正常返回信息) 及mmanos/laravel-search依赖 也相应按说明做了配置,最后写了调用程序,程序如下

<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>

访问结果如下错误,
laravel-search初试遇见的问题,求助!
小弟水平低,请指点,谢谢!!!

你看看下面的评论,目前第一条就是了。
学院君回复是:

有安装elasticsearch依赖组件吗

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn