{"id":20904598,"url":"https://github.com/ethercap/yii2-opensearch","last_synced_at":"2026-07-06T11:31:39.215Z","repository":{"id":98525490,"uuid":"99086067","full_name":"ethercap/yii2-opensearch","owner":"ethercap","description":"阿里云开放搜索","archived":false,"fork":false,"pushed_at":"2020-06-19T16:03:21.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-12T21:26:40.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethercap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-02T07:26:37.000Z","updated_at":"2020-06-19T16:03:24.000Z","dependencies_parsed_at":"2023-03-10T16:15:16.090Z","dependency_job_id":null,"html_url":"https://github.com/ethercap/yii2-opensearch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ethercap/yii2-opensearch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethercap%2Fyii2-opensearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethercap%2Fyii2-opensearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethercap%2Fyii2-opensearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethercap%2Fyii2-opensearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethercap","download_url":"https://codeload.github.com/ethercap/yii2-opensearch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethercap%2Fyii2-opensearch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35189713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T13:17:57.845Z","updated_at":"2026-07-06T11:31:39.177Z","avatar_url":"https://github.com/ethercap.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Opensearch的yii2扩展\n===============================\n阿里云的Opensearch的yii2扩展\n\n## 使用方式\n#### 1 Raw方式\n就是直接调用OpenSearch类的search/suggest方法 和opensearch通信返回结果\n#### 2 ActiveRecord类实现\n仿照yii2的db ActiveRecord的设计和调用方式\n代码放在db里面 使用的时候继承和配置SearchModel\n\nSeachModel\n===============================\n- 1 index --\u003e 定义表名\n- 2 mapping --\u003e 定义字段的类型 int / string / int_array / string_array\n- 3 search / suggest --\u003e  search/suggest 对应的instance名字 (默认就叫search/suggest)\n\nSearchQuery\n===============================\n```\n基本调用\n$modelArr = SearchModel::search()-\u003efilter()-\u003eandFilter()-\u003eorderBy()-\u003elimit()-\u003eoffset()-\u003eall();\n\nSearchModel::search() / suggest()\n-\u003eselect([]) // fields\n-\u003equery() // query\n-\u003efilter(['type' =\u003e new SearchInt(1)]) // filter //'type'=\u003e'1' 'type'=\u003e1 bigint '1234'\n-\u003eandFilter(['status' =\u003e 10]) // andWhere\n-\u003eorFilter(['like', 'catgy', 'bc']) // orWhere\n// andFilter and tag in ('8','9','10') // int string\n-\u003eandWhere(['in', 'tag', [8,9,10]])\n-\u003eall();\n```\n\nfilter的特殊之处\n===============================\n```\n本质原因是 search和sql还是有些不同的\n    int型的是通用的\n    string类型search有3中: text/shortText/literal\n        text: 用于通用的搜索分词\n        shortText: 用于实现类似like的搜索\n        literal：也就是exactly match 精准匹配\n    array类型:\n        literal_array: 用or操作来实现了 in/not in\n        int和其他类型的array: opensearch有原生的in/not in支持\n```\n\n代码结构\n-------------------\n\n```\nOpenSearch              对CloudsearchClient的原始封装\nCloudsearchClient       对Opensearch的web调用封装\ndb\n    filter/              条件过滤器的实现(and/or/in/not in)\n    BaseSearchQuery      Base的实现\n    SearchQuery          SearchQuery\n    SearchModel          SearchModel\n    TestSearchModel      示例SearchModel\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethercap%2Fyii2-opensearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethercap%2Fyii2-opensearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethercap%2Fyii2-opensearch/lists"}