<?php
$info = config('opensearch');
//开启调试模式
$options = array('debug' => false);
$client = new \OpenSearch\Client\OpenSearchClient($info['app_id'], $info['app_secret'], $info['endPoint'], $options);
// 实例化一个搜索类
$searchClient = new \OpenSearch\Client\SearchClient($client);
// 实例化一个搜索参数类
$params = new \OpenSearch\Util\SearchParamsBuilder();
//设置config子句的hit值
$params->setHits(20);
$params->setAppName('seo');
// 指定搜索关键词
$params->setQuery("default:'{$this->tag}'");
// 指定返回的搜索结果的格式为json.gitignore
$params->setFormat("fulljson");
// 执行搜索,获取搜索结果
$ret = $searchClient->execute($params->build());
$result = json_decode($ret->result,true)['result']['items'];
-
Notifications
You must be signed in to change notification settings - Fork 0
sky-L/ali-openSearch-v3
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Packages 0
No packages published