Skip to content

API 文档

Yvette Han edited this page May 27, 2021 · 1 revision

API 总览

健康管理

  • 检查编码器运行状况
  • 网路诊断

索引管理

创建索引

POST http://{{soco-search-server}}/v1/index/create

创建新的索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名 类型 需求 描述
mappings mappings Required 设置索引的映射,请参考映射的具体描述
index_id string Required 新索引的索引ID,可以为小写字母,数字,下划线或破折号的任意组合

主体示例

{
    "mappings": {
        "title": [
            {
                "targetFieldName": "title",
                "type": "keyword",
                "configs": []
            }
        ],
        "text": [
            {
                "targetFieldName": "text",
                "type": "keyword"
            },
            {
                "targetFieldName": "tss",
                "type": "term_score",
                "configs": [
                    {
                        "key": "encoder_id",
                        "value": "bert-base-uncase-ti-log-max-320head-snm"
                    }
                ]
            }
        ]
    },
    "index_id": "new-wiki-enc"
}

删除索引

POSThttp://{{soco-search-server}}/v1/index/delete_index

删除特定索引id的索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名 类型 需求 描述
index_id string 必需 待删除索引的id

主体示例

{
    "index_id": "wiki_basic"
}

重新索引

POSThttp://{{soco-search-server}}/v1/index/reindex

使用选定的数据集重新索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名 类型 需求 描述
collection_name string 必需 重新索引所需要的数据集名称
index_id string 必需 待重新索引的索引id

主体示例

{
    "collection_name": "wiki-es",
    "index_id": "wiki-es"
}

获取索引列表

GEThttp://{{r2base_url}}/r2base/v1/index/list

获取本服务器上面所有索引的id列表

路径参数

参数名 需求 描述
r2base_url Required r2base 的url

获取索引信息

GEThttp://{{r2base_url}}/r2base/v1/index/{{index_id}}

获取选定索引id的信息(索引id和大小)

路径参数

参数名 需求 描述
r2base_url Required r2base 的url
index_id 必需 需要获取信息的索引id

获取索引映射

GEThttp://{{soco-search-server}}/v1/index/get_mappings/{{index_id}}

获取选定索引id的映射信息

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url
index_id 必需 待获取映射信息的索引id

获取索引节点信息

GEThttp://{{soco-search-server}}/v1/index/node_info

获取本服务器的索引节点信息

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

获取队列中的作业信息

GEThttp://{{soco-search-server}}/v1/jobs/rq_jobs

获取队列中的作业信息

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

从特定状态重新排队

GEThttp://{{soco-search-server}}/v1/jobs/requeue/{{status}}/{{index_id}}

Requeue an index from a specific status

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url
status 必需 需要重新排入队列的索引的状态,可以为 "TO_DO", "DOING", 或 "ERROR"
index_id 必需 需要重新排入队列的索引id

数据管理

添加数据(自动)

POST http://{{soco-search-server}}/v1/data/add_data

自动添加数据至数据集中并进行索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名 类型 需求 描述
index_id string 必需 待重新索引的索引id
collection_name string 必需 数据集名称

主体示例

{
    "index_id": "test",
    "collection_name": "text",
    "docs": [
        {
            "text": "hi",
            "title": "test"
        }
    ]
}

按object ID删除

POST http://{{soco-search-server}}/v1/data/add_data

通过object id删除数据集中的特定对象

路径参数

参数名 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名 类型 需求 描述
index_id string 必需 索引id
collection_name string 必需 数据集名称
ids array/list 必需 需要删除的对象的id

主体示例

{
    "index_id": "wiki-es",
    "collection_name": "wiki-es",
    "ids": [
        "601c282035b2d7df1c4cac10",
        "601c282035b2d7df1c4cac11"
    ]
}

通过uid删除数据

DEL http://{{r2base_url}}/r2base/v1/index/{{index_id}}/docs/{{uids}}

通过uid删除数据

路径参数

参数名 需求 描述
r2base_url 必需 r2base 服务器的url
index_id 必需 索引id
uids 必需 uids

更新数据

POST http://{{soco-search-server}}/v1/data/update_data

通过doc id更新数据

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

主体参数

参数名 类型 需求 描述
index_id string 必需 索引id
collection_name string 必需 数据集名称
query object 必需 包含要更新的文档ID的查询对象
query._id string 必需 字符串中的文档ID (MongoDB _id)
update object 必需 包含所有要更新的字段的对象

主体示例

{
    "index_id": "wiki-sparta",
    "collection_name": "wiki-es",
    "query": {
        "_id": "6047beb1bb1ce75537422d6c"
    },
    "update": {
        "title": "new title"
    }
}

删除特定索引中的所有数据

DEL http://{{soco-search-server}}/v1/data/delete_all/{{index_id}}

删除特定索引中的所有数据

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引id

状态作业管理

获取状态

GET http://{{soco-search-server}}/v1/jobs/status

获取索引状态摘要

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

获取特定的index_id状态

GET http://{{soco-search-server}}/v1/jobs/status/{{index_id}}

通过索引ID获取特定索引的状态

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引 id

获取状态详细信息

GET http://{{soco-search-server}}/v1/jobs/status_detail

获取所有索引的状态详细信息

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

初始化所有状态

GET http://{{soco-search-server}}/v1/jobs/init

初始化所有索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

初始化特定状态

GET http://{{soco-search-server}}/v1/jobs/init/{{index_id}}

通过索引ID初始化一个特定的索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引的id

监视器

GET http://{{soco-search-server}}/v1/jobs/monitor

监视节点的日志

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

重新排队

GET http://{{soco-search-server}}/v1/jobs/requeue/{{index_id}}

通过索引ID重新排队某个索引

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引的id

获取错误日志

GET http://{{soco-search-server}}/v1/jobs/error_logs/{{index_id}}

通过索引ID获取特定索引的错误日志

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引的id

获取特定index_id的作业

GEThttp://{{soco-search-server}}/v1/jobs/status/{{status_name}}/{{index_id}}/{{skip}}/{{limit}}

通过索引ID获取特定索引的作业

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
status_name 必需 索引的状态,可以为 "TO_DO", "DOING", "ERROR",或 "REINDEX"
index_id 必需 索引的id
skip 必需 需要跳过的作业数量
limit 必需 一次能查询的工作数量

删除特定index_id的状态信息

DELETEhttp://{{soco-search-server}}/v1/jobs/status/{{status}}/{{index_id}}

通过索引ID删除一个索引下处于特定状态的作业

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
status_name 必需 索引的状态,可以为 "TO_DO", "DOING", "ERROR",或 "REINDEX"
index_id 必需 索引的id

获取特定index_id的进度

GET http://{{soco-search-server}}/v1/jobs/progress/{{index_id}}

通过索引ID获取特定索引的进度

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url
index_id 必需 索引的id

搜索和查询

查询

路径参数

参数名称 需求 描述
r2base_url 必需 r2base服务器的URL
index_id 必需 索引ID

主体参数

参数名称 类型 需求 描述
query object 必需 索引结果查询的对象
query.match object 必需 索引结果查询的匹配对象
query.read object 可选 使用机器阅读理解(mrc)的配置
query.read.field string 必需 要在查询中使用的源字段
query.read.query string 必需 查询与“ match”中的查询相同
query.read.top_k int 必需 排名靠前的查询结果的数量
query.read.model_id string 必需 查询将使用的模型ID

主体示例

{
    "query": {
        "match": {
            "tss": "When does bill gates born?"
        },
        "read": {
            "field": "text",
            "query": "When does bill gates born?",
            "top_k": 10,
            "model_id": "spanbert-large-squad2"
        }
    }
}

人工训练查询

POST http://{{soco-search-server}}/v1/query/hitl

路径参数

参数名 需求 描述
soco-search-server 必需 soco search服务器的url

主体参数

参数名称 类型 需求 描述
query object 必需 人工训练查询对象
query.text string 必需 人工训练查询的文本
index_id string 必需 索引id
hid string 必需 人工训练的任务ID的字符串形式(mongodb _id)
htype object 必需 是否在人工训练查询中使用同义词和反馈
htype.synonyms bool 必需 是否在人工训练中使用同义词
htype.feedback bool 必需 是否在人工训练查询中使用反馈
filter string 必需 过滤字符串(例如,输入"field = 'A' or field < 'B'")

主体示例

{
    "query": {
        "text": "用朝气蓬勃的歌声,唱出拼搏向上的青春力量"
    },
    "filter": "_doc_id='604149b66015b48a0b603581' or title='#王俊凯#  ——《明日歌》,祝同学们不负韶华[心]'",
    "hid": "606e046238f43f300398d1f6",
    "htype": {
        "synonyms": true,
        "feedback": true
    },
    "index_id": "media"
}

R2Base

获取映射(r2base)

获取r2base 的映射

路径参数

参数名称 需求 描述
r2base_url 必需 r2base服务器的URL
index_id 必需 需要获取映射的索引id

删除查询(r2base)

POSThttp://{{r2base_url}}/r2base/v1/search/{{index_id}}/delete_query

删除r2base的查询

路径参数

参数名称 需求 描述
r2base_url 必需 r2base服务器的URL
index_id 必需 需要删除的索引id

主线示例

{"query":{"filter":"*"}}

人工训练

注册人工训练

POST http://{{soco-search-server}}/v1/human-in-the-loop/register

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名称 类型 需求 描述
name string 必需 想要创建的人工训练任务名称
index_id string 必需 人工训练所要用到的索引id
collection_name string 必需 与人工训练任务相联系的数据集名称
lang string 必需 人工训练查询中使用的语言

主体示例

{
    "index_id": "synonyms",
    "name": "synonyms1",
    "collection_name": "wiki-es",
    "lang": "en"
}

获取人工训练

GET http://{{soco-search-server}}/v1/human-in-the-loop/register

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url

删除人工训练

DELETE http://{{soco-search-server}}/v1/human-in-the-loop/register/{{id}}

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url
id 必需 人工训练任务的id (mongodb _id)

添加同义词

POST http://{{soco-search-server}}/v1/human-in-the-loop/add_synonyms

在人工训练任务中添加新的同义词信息

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名称 类型 需求 描述
query string 必需 用户使用在人工训练中的查询
synonyms array 必需
hid string 必需 人工训练任务的id
filter string 必需 字符串模式的过滤器 (e.g. 输入 "field = 'A' or field < 'B'")

删除同义词

DELETE http://{{soco-search-server}}/v1/human-in-the-loop/delete_synonyms/{{synonym_id}}

删除特定的同义词信息

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url
synonym_id Yes 要删除的同义词id (mongodb _id)

添加相关反馈

POST http://{{soco-search-server}}/v1/human-in-the-loop/add_relevance_feedback

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名称 类型 需求 描述
query string 必需 用户使用在人工训练中的查询
doc object 必需 包含最佳结果的文档id (e.g. { "_doc_id": "6047beabbb1ce75537422af2" })
hid string 必需 人工训练任务的id
filter string 必需 字符串模式的过滤器 (e.g. 输入 "field = 'A' or field < 'B'")

主体示例

{
    "hid": "606cb38ab6e4713a0e05cbea",
    "query": "what language did people speak in Brazil?",
    "doc": {
        "_doc_id": "6047beabbb1ce75537422af2"
    },
    "filter": "_doc_id='604159676015b48a0b7ddee0' or title='滕州交通违章曝光:这些路段违停将被抓拍!'"
}

删除相关反馈

DELETE http://{{soco-search-server}}/v1/human-in-the-loop/delete_relevance_feedback/{{feedback_id}}

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url
feedback_id 必需 要删除的反馈id (mongodb _id)

同义词推荐

POST http://{{soco-search-server}}/v1/human-in-the-loop/recommend_synonyms

基于查询请求的文本智能推荐对应的同义词

路径参数

参数名称 需求 描述
soco-search-server 必需 soco search 服务器的url

主体参数

参数名称 类型 需求 描述
query string 必需 用户使用在人工训练中的查询
lang string 必需 人工训练任务的语言, 英文"en" 或者中文 "zh"

主体示例

{
    "query": "用朝气蓬勃的歌声,唱出拼搏向上的青春力量",
    "lang": "zh"
}
Clone this wiki locally