# 全文检索

功能

根据关键词搜索文件、文件夹名称、内容,支持单字匹配搜索、中英文分词搜索、拼音搜索。

提示

全文检索现在支持通过文件名搜索云盘文件了。

最多返回 300 条数据。

路径fs/bs/search

请求方法GET

请求参数

参数 必须 类型 备注
keyWords string 搜索关键词
nameLimit number 名称返回的最大长度
contentLimit number 内容返回的最大长度
appUserId string 业务用户 ID
excludeAncestorFidList string 搜索结果中剔除此文件(夹)下的子孙文件

请求示例

点击查看
export async function GET(
  keyWords: string,
  nameLimit: number,
  contentLimit: number,
  appUserId: string,
  excludeAncestorFidList?: string[]
): Promise<ResponseBody<IflydocsSearchResultItem[]>> {
  const method = 'GET'
  const path = '/fs/bs/search'
  const { nonce, timestamp } = genNonce()

  const signature = sign(method, path, nonce, timestamp)
  const Authorization = authorization(signature)

  const headers = {
    Authorization,
    nonce,
    timestamp,
  }

  const params = {
    keyWords,
    nameLimit,
    contentLimit,
    appUserId,
    excludeAncestorFidList,
  }

  const resp = await axios.get(path, {
    params,
    paramsSerializer: (params) => qs.stringify(params),
    headers,
  })

  return resp.data
}

响应示例

点击查看
{
  "code": 0,
  "message": "success",
  "data": [
    {
      "fid": "10td1",
      "owner": 1657589576821,
      "sourceId": "10td1",
      "creator": 1657589576821,
      "spaceType": 1,
      "docType": "note",
      "modifier": 1657589576821,
      "suffix": "note",
      "type": 2,
      "content": "\n",
      "parentFid": "10td2",
      "path": "/10td2/10td1",
      "score": 25.94719,
      "modifyTime": 1666859336851,
      "createTime": 1666859336851,
      "sourceType": 1,
      "appId": "6da37dd3",
      "name": "st-<em>move</em>-fi",
      "fileType": 1
    },
    {
      "fid": "10td2",
      "owner": 1657589576821,
      "creator": 1657589576821,
      "spaceType": 1,
      "modifier": 1657589576821,
      "type": 1,
      "content": null,
      "parentFid": "0",
      "path": "/10td2",
      "score": 25.35985,
      "modifyTime": 1666859337073,
      "createTime": 1666859337073,
      "appId": "6da37dd3",
      "name": "st-<em>move</em>-fo"
    }
  ]
}