首页 > 后端开发 > php教程 > laravel-search初试遇见的问题,求助!

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

WBOY
发布: 2016-07-06 13:51:57
原创
883 人浏览过

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

<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依赖 也相应按说明做了配置,最后写了调用程序,程序如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

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

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板