• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

请大神帮解答一下`elasticsearch`的相关问题,看文档看不出个步骤来

php 搞代码 4年前 (2022-01-23) 26次浏览 已收录 0个评论
文章目录[隐藏]

已完成工作描述:

1、已在本地windows机器上安装好了elasticsearch及相关插件。

2、然后在laravel中安装好了elasticsearch-php客户端。

3、写了如下这么一个SearchController控制器:

<code><?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use App\Http\Requests;class SearchController extends Controller{    protected $client;    public function __construct() {        $this->client = \Elasticsearch\ClientBuilder::create()->build();    }    public function index()    {        $params = [            'index' => 'node',            'type' => 'article',            'body' => [                'query' => [                    'match_all' => []                ]            ]        ];        $response = $this->client->search($params);        print_r($response);    }    public function create()    {        $params = [            'index' => 'node',            '<mark>@本文来源gaodaimacom搞#代%码@网-</mark><strong>搞代gaodaima码</strong>type' => 'article',            'id' => '1029',            'body' => [                'query' => [                    'match_all' => []                ]            ]        ];        $response = $this->client->index($params);        print_r($response);    }    public function store(Request $request)    {    }    public function show($id)    {    }    public function edit($id)    {    }    public function update(Request $request, $id)    {    }    public function destroy($id)    {            }}</code>

问题描述:

1、虽然完成了以上3步,但现在没有头绪,看文档也看不出个步骤来。具体表现就是:假如我现在就要对一个名为articles的数据表进行索引和查询,还需要做什么?最好说一下每一步怎么做。谢谢。

2、’index’ 、 ‘type’ 、’body’是什么含义?

3、如果不用mysql,直接使用ES保存索引,那索引文件默认在什么目录?

回复内容:

已完成工作描述:

1、已在本地windows机器上安装好了elasticsearch及相关插件。

2、然后在laravel中安装好了elasticsearch-php客户端。

3、写了如下这么一个SearchController控制器:

<code><?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use App\Http\Requests;class SearchController extends Controller{    protected $client;    public function __construct() {        $this->client = \Elasticsearch\ClientBuilder::create()->build();    }    public function index()    {        $params = [            'index' => 'node',            'type' => 'article',            'body' => [                'query' => [                    'match_all' => []                ]            ]        ];        $response = $this->client->search($params);        print_r($response);    }    public function create()    {        $params = [            'index' => 'node',            'type' => 'article',            'id' => '1029',            'body' => [                'query' => [                    'match_all' => []                ]            ]        ];        $response = $this->client->index($params);        print_r($response);    }    public function store(Request $request)    {    }    public function show($id)    {    }    public function edit($id)    {    }    public function update(Request $request, $id)    {    }    public function destroy($id)    {            }}</code>

问题描述:

1、虽然完成了以上3步,但现在没有头绪,看文档也看不出个步骤来。具体表现就是:假如我现在就要对一个名为articles的数据表进行索引和查询,还需要做什么?最好说一下每一步怎么做。谢谢。

2、’index’ 、 ‘type’ 、’body’是什么含义?

3、如果不用mysql,直接使用ES保存索引,那索引文件默认在什么目录?

最近也是刚接触了es

es可以对应一个mysql数据库

index的概念就相当于库
type的概念就相当于表
document就相当于记录

那么你要操作,你首先要有个库,要有个表,才能进行增删查改

怎么索引和搜索去看文档吧

索引文件以文件形式存储在ES_HOME/data

logstash的jdbc插件你可以去官网找,jdbc官方文档


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:请大神帮解答一下`elasticsearch`的相关问题,看文档看不出个步骤来

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址