<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
// 获取文档
$params = [
'index' => 'my_user',
'type' => 'my_user',
'id' => 1
];
// http://localhost:9200/my_user/my_user/1
// $response = $client->get($params);
// print_r($response);
// 搜索文档
$params = [
'index' => 'my_user',
'type' => 'my_user',
'body' => [
'query' => [
'match' => [
'name' => '张三'
]
]
]
];
$results = $client->search($params);
print_r($results);
echo "<hr/>".PHP_EOL;
$params = [
'index' => 'my_user',
'type' => 'my_user',
'body' => [
'query' => [
'bool' => [
'must' => [
[ 'match' => [ 'name' => '张三' ] ],
]
]
]
]
];
$results = $client->search($params);
print_r($results);
5.elasticsearch-php索引文档搜索文档
猜你喜欢
转载自blog.csdn.net/qq_39337886/article/details/103802019
今日推荐
周排行