时间:2021-07-01 10:21:17 帮助过:40人阅读
1、已在本地windows机器上安装好了elasticsearch及相关插件。
2、然后在laravel中安装好了elasticsearch-php客户端。
3、写了如下这么一个SearchController控制器:
- <code><!--?php
- namespace 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保存索引,那索引文件默认在什么目录?
已完成工作描述:
1、已在本地windows机器上安装好了elasticsearch及相关插件。
2、然后在laravel中安装好了elasticsearch-php客户端。
3、写了如下这么一个SearchController控制器:
- <code><!--?php
- namespace 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官方文档