A developer fine-tunes a custom embedding or reranking model on PAI, deploys it to Bailian as a managed inference endpoint for OpenSearch neural reranking, and additionally configures Elasticsearch-specific relevance optimizations including synonym dictionaries and spelling correction across a hybrid search architecture spanning both engines.
Use this workflow when your application requires domain-specific search relevance that out-of-the-box lexical matching cannot achieve. By fine-tuning a custom embedding or reranking model on PAI and deploying it via Bailian, you enable neural reranking in OpenSearch while maintaining Elasticsearch’s mature synonym and spelling correction pipelines across a unified hybrid search architecture.
ossutil cp ./domain_train.jsonl oss://my-bucket/pai-data/
pai job submit --name reranker-ft --image registry.cn-hangzhou.aliyuncs.com/pai/pytorch:2.0 --script train.py --data oss://my-bucket/pai-data/ --output oss://my-bucket/pai-models/ --gpu-count 1
curl -X POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation \ -H "Authorization: Bearer $BAILIAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "custom-reranker-v1", "input": {"prompt": "score query vs doc"}}'
``json PUT /opensearch-index/_settings { "neural_search.reranker": { "endpoint": "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation", "api_key": "$BAILIAN_API_KEY", "model_id": "custom-reranker-v1", "top_k": 50, "timeout_ms": 800 } } ``
``json PUT /es-index { "settings": { "analysis": { "filter": { "synonyms": { "type": "synonym", "synonyms_path": "analysis/domain_synonyms.txt" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "standard", "fields": { "suggest": { "type": "completion", "preserve_separators": true } } } } } } ``
suggest), fetch top-50 candidates, then pass them to OpenSearch for Bailian-backed neural reranking.Training data flows from OSS into PAI for GPU-accelerated fine-tuning. The resulting model artifact is registered in Bailian, which exposes a low-latency REST inference endpoint. OpenSearch consumes this endpoint exclusively for post-retrieval neural reranking, while Elasticsearch handles pre-retrieval lexical expansion (synonyms, spelling correction). The application orchestrates a two-stage pipeline: ES retrieves candidates, then OpenSearch reranks them using the Bailian-hosted model.
domain_synonyms.txt and aligned query-document pairsscore field expected by the reranker.top_k ≤100 and enable HTTP keep-alive to prevent connection timeouts.POST /_reload_search_analyzers. Automate this in CI/CD to avoid stale expansions.knn scores differently. Standardize query DSL templates and apply explicit boost values to maintain consistent ranking across engines.Q: How can I optimize search relevance with a custom model across Elasticsearch and OpenSearch? A: You can achieve this by fine-tuning a custom embedding or reranking model on PAI and deploying it to Bailian as a managed inference endpoint for OpenSearch neural reranking. This configuration enables Elasticsearch-specific relevance optimizations, including synonym dictionaries and spelling correction, across a hybrid search architecture spanning both engines.