
Alicloud Ai Search Opensearch
- 276 installs
- 396 repo stars
- Updated July 18, 2026
- cinience/alicloud-skills
alicloud-ai-search-opensearch is an agent skill that configures Alibaba Cloud OpenSearch vector search via the ha3engine Python SDK for developers building hybrid full-text and vector RAG retrieval.
About
alicloud-ai-search-opensearch is an agent skill from cinience/alicloud-skills focused on API and SDK usage—no console walkthroughs. It uses the alibabacloud-ha3engine Python package to push documents with push_documents and run HA or SQL-style searches for hybrid keyword plus vector retrieval in production apps. Configuration is environment-driven across OPENSEARCH_ENDPOINT, OPENSEARCH_INSTANCE_ID, OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD, OPENSEARCH_DATASOURCE, plus optional OPENSEARCH_PK_FIELD and OPENSEARCH_CLUSTER defaults. Developers reach for this skill when wiring catalog search, documentation lookup, support knowledge bases, or RAG pipelines on Alibaba Cloud. Queries larger than 30KB should use the RESTful search API instead of inline HA query strings.
- OpenSearch domain and index setup
- Full-text plus vector hybrid queries
- Ingestion pipelines and analyzers
- Relevance tuning and faceting
- Secure API access for app search
Alicloud Ai Search Opensearch by the numbers
- 276 all-time installs (skills.sh)
- Ranked #2,396 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cinience/alicloud-skills --skill alicloud-ai-search-opensearchAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 276 |
|---|---|
| repo stars | ★ 396 |
| Last updated | July 18, 2026 |
| Repository | cinience/alicloud-skills ↗ |
How do you query Alibaba Cloud OpenSearch from Python?
Configure Alibaba Cloud OpenSearch for AI-enhanced full-text and vector hybrid search across catalogs, docs, and support knowledge in production apps.
Who is it for?
Backend developers building RAG or hybrid search on Alibaba Cloud OpenSearch Vector Search Edition with the ha3engine Python SDK.
Skip if: Teams using only the OpenSearch web console, non-Alibaba search engines, or projects without Python SDK integration requirements.
When should I use this skill?
The user asks to push documents to OpenSearch, run HA or SQL searches, or build RAG retrieval on Alibaba Cloud OpenSearch.
What you get
Configured OpenSearch environment variables, document push calls, HA query strings, and SQL search requests against indexed vectors and text.
- Document ingestion scripts
- HA and SQL search queries
- RAG retrieval integration code
By the numbers
- Requires 5 OPENSEARCH_* environment variables for SDK authentication and datasource access
- Recommends RESTful search API when query strings exceed 30KB
Files
Category: provider
OpenSearch Vector Search Edition
Use the ha3engine SDK to push documents and execute HA/SQL searches. This skill focuses on API/SDK usage only (no console steps).
Prerequisites
- Install SDK (recommended in a venv to avoid PEP 668 limits):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install alibabacloud-ha3engine- Provide connection config via environment variables:
OPENSEARCH_ENDPOINT(API domain)OPENSEARCH_INSTANCE_IDOPENSEARCH_USERNAMEOPENSEARCH_PASSWORDOPENSEARCH_DATASOURCE(data source name)OPENSEARCH_PK_FIELD(primary key field name)
Quickstart (push + search)
import os
from alibabacloud_ha3engine import models, client
from Tea.exceptions import TeaException, RetryError
cfg = models.Config(
endpoint=os.getenv("OPENSEARCH_ENDPOINT"),
instance_id=os.getenv("OPENSEARCH_INSTANCE_ID"),
protocol="http",
access_user_name=os.getenv("OPENSEARCH_USERNAME"),
access_pass_word=os.getenv("OPENSEARCH_PASSWORD"),
)
ha3 = client.Client(cfg)
def push_docs():
data_source = os.getenv("OPENSEARCH_DATASOURCE")
pk_field = os.getenv("OPENSEARCH_PK_FIELD", "id")
documents = [
{"fields": {"id": 1, "title": "hello", "content": "world"}, "cmd": "add"},
{"fields": {"id": 2, "title": "faq", "content": "vector search"}, "cmd": "add"},
]
req = models.PushDocumentsRequestModel({}, documents)
return ha3.push_documents(data_source, pk_field, req)
def search_ha():
# HA query example. Replace cluster/table names as needed.
query_str = (
"config=hit:5,format:json,qrs_chain:search"
"&&query=title:hello"
"&&cluster=general"
)
ha_query = models.SearchQuery(query=query_str)
req = models.SearchRequestModel({}, ha_query)
return ha3.search(req)
try:
print(push_docs().body)
print(search_ha())
except (TeaException, RetryError) as e:
print(e)Script quickstart
python skills/ai/search/alicloud-ai-search-opensearch/scripts/quickstart.pyEnvironment variables:
OPENSEARCH_ENDPOINTOPENSEARCH_INSTANCE_IDOPENSEARCH_USERNAMEOPENSEARCH_PASSWORDOPENSEARCH_DATASOURCEOPENSEARCH_PK_FIELD(optional, defaultid)OPENSEARCH_CLUSTER(optional, defaultgeneral)
Optional args: --cluster, --hit, --query.
SQL-style search
from alibabacloud_ha3engine import models
sql = "select * from <indexTableName>&&kvpair=trace:INFO;formatType:json"
sql_query = models.SearchQuery(sql=sql)
req = models.SearchRequestModel({}, sql_query)
resp = ha3.search(req)
print(resp)Notes for Claude Code/Codex
- Use
push_documentsfor add/delete updates. - Large query strings (>30KB) should use the RESTful search API.
- HA queries are fast and flexible for vector + keyword retrieval; SQL is helpful for structured data.
Error handling
- Auth errors: verify username/password and instance access.
- 4xx on push: check schema fields and
pk_fieldalignment. - 5xx: retry with backoff.
Validation
mkdir -p output/alicloud-ai-search-opensearch
for f in skills/ai/search/alicloud-ai-search-opensearch/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alicloud-ai-search-opensearch/validate.txtPass criteria: command exits 0 and output/alicloud-ai-search-opensearch/validate.txt is generated.
Output And Evidence
- Save artifacts, command outputs, and API response summaries under
output/alicloud-ai-search-opensearch/. - Include key parameters (region/resource id/time range) in evidence files for reproducibility.
Workflow
1) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating. 2) Run one minimal read-only query first to verify connectivity and permissions. 3) Execute the target operation with explicit parameters and bounded scope. 4) Verify results and save output/evidence files.
References
- SDK package:
alibabacloud-ha3engine - Demos: data push and HA/SQL search demos in OpenSearch docs
- Source list:
references/sources.md
interface:
display_name: "Alibaba Cloud AI Search OpenSearch"
short_description: "OpenSearch vector indexing and query"
default_prompt: "Use $alicloud-ai-search-opensearch to complete this ai/search task on Alibaba Cloud."
官方文档来源(用于后续更新) ============================
- (暂无外部文档链接)
import argparse
import os
import sys
from alibabacloud_ha3engine import client, models
from Tea.exceptions import TeaException, RetryError
def get_env(name: str, default: str | None = None) -> str:
value = os.getenv(name, default)
if not value:
print(f"Missing env var: {name}", file=sys.stderr)
sys.exit(1)
return value
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="OpenSearch vector quickstart")
parser.add_argument("--cluster", default=os.getenv("OPENSEARCH_CLUSTER", "general"))
parser.add_argument("--hit", type=int, default=5)
parser.add_argument("--query", default="title:hello")
return parser.parse_args()
def main() -> None:
args = parse_args()
cfg = models.Config(
endpoint=get_env("OPENSEARCH_ENDPOINT"),
instance_id=get_env("OPENSEARCH_INSTANCE_ID"),
protocol="http",
access_user_name=get_env("OPENSEARCH_USERNAME"),
access_pass_word=get_env("OPENSEARCH_PASSWORD"),
)
ha3 = client.Client(cfg)
data_source = get_env("OPENSEARCH_DATASOURCE")
pk_field = get_env("OPENSEARCH_PK_FIELD", "id")
documents = [
{"fields": {"id": 1, "title": "hello", "content": "world"}, "cmd": "add"},
{"fields": {"id": 2, "title": "faq", "content": "vector search"}, "cmd": "add"},
]
try:
print("Pushing docs...")
req = models.PushDocumentsRequestModel({}, documents)
resp = ha3.push_documents(data_source, pk_field, req)
print(resp.body)
print("Searching...")
query_str = (
f"config=hit:{args.hit},format:json,qrs_chain:search"
f"&&query={args.query}"
f"&&cluster={args.cluster}"
)
ha_query = models.SearchQuery(query=query_str)
req = models.SearchRequestModel({}, ha_query)
resp = ha3.search(req)
print(resp)
except (TeaException, RetryError) as exc:
print(exc)
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
How it compares
Use this skill for Alibaba Cloud OpenSearch Vector Search Edition SDK work; pick sibling DashVector skills when the vector store is DashVector instead.
FAQ
Which SDK does alicloud-ai-search-opensearch use?
alicloud-ai-search-opensearch uses the alibabacloud-ha3engine Python SDK. Install it with pip in a virtual environment, then call push_documents and search APIs without using the OpenSearch console.
What environment variables are required?
alicloud-ai-search-opensearch requires OPENSEARCH_ENDPOINT, OPENSEARCH_INSTANCE_ID, OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD, and OPENSEARCH_DATASOURCE. OPENSEARCH_PK_FIELD and OPENSEARCH_CLUSTER are optional with defaults.
When should HA queries use the REST API?
alicloud-ai-search-opensearch recommends the RESTful search API when HA query strings exceed 30KB. Smaller HA and SQL queries can run through the ha3engine SDK search methods.