按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>
|
登录后复制
登录后复制
访问结果如下错误,
小弟水平低,请指点,谢谢!!!
回复内容:
按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>
|
登录后复制
登录后复制
访问结果如下错误,
小弟水平低,请指点,谢谢!!!
你看看下面的评论,目前第一条就是了。
学院君回复是:
有安装elasticsearch依赖组件吗