加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

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;
}
 
添加

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有