PHPackages                             mofing/opensearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mofing/opensearch

ActiveLibrary[API Development](/categories/api)

mofing/opensearch
=================

opensearch-sdk-php

1.0.5(6y ago)1893↓50%MITPHPPHP &gt;=5.6

Since Jun 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wcj343169893/openSearch)[ Packagist](https://packagist.org/packages/mofing/opensearch)[ RSS](/packages/mofing-opensearch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

openSearch php for aliyun
=========================

[](#opensearch-php-for-aliyun)

基于官方opensearch-sdk-PHP 改版

安装
--

[](#安装)

```
$ composer install "mofing/opensearch":"~1.0"
```

或者修改composer.json

```
{
    "require": {
        "mofing/opensearch": "~1.0"
    }
}

```

用法
--

[](#用法)

\###1.获取key和secret 在  下的Access Key管理，可以适用阿里云的很多sdk，所以建议写成静态变量

```
$accessKey = "LTAICZ5bcHEHwg3d";//Access Key ID
$secret = "kFLCYaxTFedSNh9rJcjM3KHBkDoxlc";//Access Key Secret
```

\###2.配置搜索参数

```
$host = "http://opensearch-cn-hangzhou.aliyuncs.com";//公网API域名或者内网API域名
$options = [
    'debug' => true
];
//初始化授权
$openSearchClient = new OpenSearchClient($accessKey, $secret, $host, $options);
//初始化搜索客户端
$searchClient = new SearchClient($openSearchClient);
//设置搜索参数
$params = new SearchParamsBuilder();
//设置config子句的start值
$params->setStart(0);
//设置config子句的hit值
$params->setHits(20);
// 指定一个应用用于搜索
$params->setAppName('mofing_shops');
// 指定搜索关键词
$params->setQuery("title:'深圳'");
// 指定返回的搜索结果的格式为json
$params->setFormat("json");
//添加排序字段
//$params->addSort('id', SearchParamsBuilder::SORT_DECREASE);
// 执行搜索，获取搜索结果
$ret = $searchClient->execute($params->build());
// 将json类型字符串解码
$result = $ret->getItems();
//$result = json_decode($ret->result);
print_r($result);
```

\--返回值

```
Array
(
    [0] => stdClass Object
        (
            [id] => 3217306
            [title] => 深圳
            [index_name] => name
        )

    [1] => stdClass Object
        (
            [id] => 2689102
            [title] => 深圳 i 摄摄影培训
            [index_name] => name
        )
)

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Recently: every ~105 days

Total

6

Last Release

2455d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ba50770ab3b983b6876cc5d96fb7915f8f1ff6efeb560de643d7c6948aa8f56?d=identicon)[wcj343169893](/maintainers/wcj343169893)

---

Top Contributors

[![wcj343169893](https://avatars.githubusercontent.com/u/502789?v=4)](https://github.com/wcj343169893 "wcj343169893 (10 commits)")[![ashe717](https://avatars.githubusercontent.com/u/30425811?v=4)](https://github.com/ashe717 "ashe717 (2 commits)")

---

Tags

sdkopensearchaliyun

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mofing-opensearch/health.svg)

```
[![Health](https://phpackages.com/badges/mofing-opensearch/health.svg)](https://phpackages.com/packages/mofing-opensearch)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
