构建一个基于 OpenSearch 的佛教文献检索系统,支持 巴利文、中文、英文 的多语种搜索,覆盖经文、译文、字典等资源,满足以下核心需求:
系统需要存储和检索以下资源:
字典
巴利语经文
译文
| 字段 | 类型 | 说明 |
|---|---|---|
id |
string | 文档唯一 ID |
resource_id |
uuid | 文档在数据库中的 id |
resource_type |
string | 文档类型,例如 article / term / dictionary / translation / pali_text |
title |
string | 文档标题,可以是中文或巴利文 |
summary |
string | 文档摘要 纯文本 |
content |
string | 文档主体内容,支持 Markdown,可能包含黑体字 |
content_vector |
dense_vector | 文档主体内容的 embedding, |
related_id |
string | 用于关联的 ID 段落 id 句子 id |
bold_single |
string | 单个黑体文本,用于搜索加权 |
bold_multi |
string | 多个黑体文本,用于搜索加权 |
page_refs |
array | 页码标记数组,例如 ["V3.81","M3.58",“PTS Vin II 57”] |
tags |
array | 文档主题标签 |
category |
array | 文档分类,例如 ["sutta", "vinaya"] |
author |
string | 作者或译者 |
language |
string | 资源语言 pali,zh-Hans,zh-Hant,en-US,my 等 |
updated_at |
date | 原始文档更新时间 |
全文搜索
page_refs 页码搜素过滤/精确查询
tags 过滤主题category 过滤文献分类黑体字搜索加权
bold_single bold_multi(Markdown 黑体),排名靠前语义搜索
vector 检索相似句子vector 检索不同语言相似句子
-巴利相似句
页码搜索
page_refs简繁体互查
处理变音符号
模糊搜索+精确匹配
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "icu_analyzer",
"fields": {
"raw": { "type": "keyword" }
// 精确匹配整段内容或句子
}
}
}
},
"settings": {
"analysis": {
"analyzer": {
"icu_analyzer": {
"tokenizer": "icu_tokenizer",
"filter": ["icu_folding", "lowercase"]
}
}
}
}
}
模糊搜索(支持巴利 diacritics 和英文转写)
{
"query": {
"match": {
"content": "mettā"
}
}
}
精确匹配(只要完全等于)
{
"query": {
"term": {
"title.raw": "mettā"
}
}
}
analysis-icuicu_transform适合快速上线,效果好,但依赖外部服务。
text-embedding-3-small支持 100+ 语言(含中文、英文、缅文)。
1536 维向量。
专门为跨语言搜索优化。
部署成本:只需 API 调用。
场景:最稳妥,适合你的「用户用中文 → 检索缅文/英文/巴利文」需求。
curl https://api.openai.com/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-embedding-3-small",
"input": "佛陀在祇园精舍说法"
}'
15 token
Prices per 1M tokens.
| Model | Cost | Batch cost |
|---|---|---|
| text-embedding-3-small | $0.02 | $0.01 |
| text-embedding-3-large | $0.13 | $0.065 |
Cohere - embed-multilingual-v3.0