gesof/elastic-search
Composer 安装命令:
composer require gesof/elastic-search
包简介
Elastic Search utility
README 文档
README
$text = 'UFOs over China';
$hosts = [
'localhost:9200',
];
$client = \Elastic\Elasticsearch\ClientBuilder::create()
->setHosts($hosts)
->build();
$qb = new \Gesof\ElasticSearch\QueryBuilder($client);
$qb
->setTable('posts')
->orderBy('_id', 'desc')
;
$andX = $qb->expr()->andX();
$andX->add($qb->expr()->eq('is_completed', TRUE));
$andX->add($qb->expr()->gt('view_count', 10));
$orX = $qb->expr()->orX();
$orX->add($qb->expr()->matchText('title', $text));
$orX->add($qb->expr()->matchText('description', $text));
$andX->add($orX);
$qb->where($andX);
$qb
->setMaxResults(10)
->setFirstResult(0)
;
$resultCount = $qb->getQuery()->count()->getCount();
$documents = $qb->getQuery()->search()->getDocuments();
foreach ($documents as $document) {
// echo $document->title . '<br />';
}
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-08