skylee/ali-open-search-v3

There is no license information available for the latest version (1.0.2) of this package.

openSearch v3

1.0.2 2018-01-12 08:28 UTC

This package is auto-updated.

Last update: 2024-11-09 15:25:59 UTC


README

快速开始

    <?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'];