PHPes高亮显示
(2023-06-03 22:46:32)分类: 数据库es |
转:https://blog.csdn.net/m0_58861359/article/details/127500534
public function __construct()
{$this->client=ClientBuilder::create()->setHosts(['127.0.0.1:9200'])->build();
}
public function es($index,$type,$id,$body)
{
$params=[
'index'=>$index,
'type'=>$type,
'id'=>$id,
'body'=>$body
];
$res=$this->client->index($params);
return $res;
}
public function ess($index,$type,$body)
{
$params = [
'index'=>$index,
'type'=>$type,
'body'=>[
'query'=>[
'match'=>[
'title'=>$body
]
],
'highlight'=>[
'pre_tags'=>[""],
'post_tags'=>[""],
'fields'=>[
'title'=> new \stdClass()
]
]
]
];
$res=$this->client->search($params);
return $res;
}
添加