Rumah  >  Artikel  >  pembangunan bahagian belakang  >  laravel-search初试遇见的问题,求助!

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

WBOY
WBOYasal
2016-07-06 13:51:57853semak imbas

按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依赖组件吗

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn