功能描述
用于搜索目录与文件。
说明:
使用本接口发起异步搜索任务时,接口将在大约2s的时间返回,如果在返回时有部分或全部搜索结果,则返回已搜索出的结果的第一页(每页20个),如果暂未搜索到结果则返回空数组,因此该接口实际返回的 contents 数量可能为0到20之间不等,且是否还有更多搜索结果,不应参考 contents 的数量,而应参考 hasMore 字段。
当需要获取后续页时,使用 继续获取搜索结果 接口。
请求
请求示例
POST /api/v1/search/{LibraryId}/{SpaceId}/space-contents?access_token={AccessToken}&user_id={UserId}
请求参数
请求体
application/json,指定搜索的条件。
请求体示例:
{"keyword": "身份证","scope": "个人文件/证件","type": "image","extname": [".png", ".jpg"],"minFileSize": 1024,"maxFileSize": 2048,"modificationTimeStart": "2022-07-26T02:58:09.000Z","modificationTimeEnd": "2022-07-26T02:58:19.000Z","orderBy": "name","orderByType": "asc", // asc/desc"searchMode": "fast", // fast/normal"labels": ["大象"],"categories ": ["zip"]}
请求体字段说明:
请求参数 | 描述 | 类型 | 是否必选 |
keyword | 搜索关键字,可使用空格分隔多个关键字,关键字之间为“或”的关系并优先展示匹配关键字较多的项目 | String | 是 |
scope | 搜索范围,指定搜索的目录,如搜索根目录可指定为空字符串、“/”或不指定该字段 | String | 否 |
extname | 搜索文件后缀 | String Array | 是 |
type | 搜索类型,可选参数,字符串或字符串数组,可反选(!)。当前支持的类型包括: all: 搜索所有类型文件和文件夹,当不传 type 或传空时默认为 all,反选时传 !all dir: 仅搜索目录,不搜索文件,反选时传 !dir file: 仅搜索所有类型文件,不搜索目录,反选时传 !file doc、xls 或 ppt: 仅搜索 Word、Excel 或 Powerpoint 类型文档,对应的文件扩展名为 .doc(x)、.xls(x) 或 .ppt(x),反选时传 !doc、!xls 或 !ppt pdf 或 txt: 仅搜索 PDF 或纯文本类型文档,对应的文件扩展名为 .pdf 或 .txt,支持反选,反选时传 !pdf 或 !txt image、video 或 audio: 仅搜索图片、视频或音频类型文件,对应的文件 MIME(Content Type)分别为 image/\\*、video/\\* 或 audio/\\*,反选时传 !image、!video 或 !audio powerpoint: 仅搜索演示文稿,如 .ppt、.pptx、.pot、.potx 等,反选时传 !powerpoint excel: 仅搜索表格文件,如 .xls、.xlsx、.ett、.xltx、.csv 等,反选时传 !excel word: 仅搜索文档,如 .doc、.docx、.dot、.wps、.wpt 等,反选时传 !word text: 仅搜索纯文本,如 .txt、.asp、.htm 等,反选时传 !text | String/String Array | 否 |
minFileSize/maxFileSize | 搜索文件大小范围,单位 Byte | Int | 否 |
modificationTimeStart/modificationTimeEnd | 搜索更新时间范围,与时区无关 | String | 否 |
orderBy | 排序字段,当前支持按名称、修改时间、文件大小、创建时间排序具体类型如下: name:按名称排序 modificationTime:按修改时间排序 size:按文件大小排序 creationTime:按创建时间排序 localCreationTime:按照文件对应的本地创建时间排序 localModificationTime:按照文件对应的本地修改时间排序 | String | 否 |
orderByType | 排序方式,升序为 asc,降序为 desc | String | 否 |
searchMode | 搜索方式,快速为 fast,普通为 normal,默认 normal | String | 否 |
labels | 简易文件标签 | String Array | 否 |
categories | 文件自定义分类信息 | String Array | 否 |
响应
响应码
搜索成功,返回 HTTP 200 OK。
响应体
application/json
响应体示例:
{"searchId": "FnMwV3NweXJOU2hTOTRpTnF0TW9EZVEeVUFhYUl5TGFSaTZtZUpDcEpUcEtxdzo3NjQ3NjU1","searchFinished": true,"hasMore": true,"nextMarker": 20,"contents": [{"type": "file","inode": "xxxx","name": "api.zip","creationTime": "2021-08-19T04:40:01.000Z","modificationTime": "2021-08-19T04:40:01.000Z","contentType": "application/zip","size": "67084","eTag": "\\"52c2d19d61fae57d11caabe87f71de73\\"","isFavorite": true,"crc64": "8970780629994048831","versionId":2,"metaData": {"x-smh-meta-creation-date": "Thu, 19 Aug 2021 04:39:59 GMT"},"path": ["api.zip"],"userId": "12","localCreationTime": "2020-09-22T07:44:45.000Z","localModificationTime": "2020-09-22T07:44:45.000Z","authorityList": {"canView": true,"canPreview": true,"canDownload": true,"canPrint": true,"canUpload": true,"canDelete": true,"canModify": true,"canAuthorize": true,"canShare": true,"canPreviewSelf": true,"canDownloadSelf": true},"authorityButtonList": {"showViewButton": true,"showPreviewButton": true,"showDownloadButton": true,"showUploadButton": true,"showDeleteButton": true,"showAuthorizeButton": true,"showShareButton": true,"showModifyButton": true,"showMoveButton": true,"showRenameButton": true,"showCopyButton": true,"showRestoreButton": true}},{"type": "file","inode": "xxxx","name": "bmw (1).PDF","creationTime": "2021-08-21T07:56:32.000Z","modificationTime": "2021-08-21T07:56:32.000Z","contentType": "application/pdf","size": "241674","eTag": "\\"030ca96f0af3b3d3cfbf31c2be3129d6\\"","isFavorite": false,"crc64": "12098979488941977387","metaData": {"x-smh-meta-creation-date": "Sat, 21 Aug 2021 07:56:30 GMT"},"path": ["abc", "bmw (1).PDF"],"userId": "12","localCreationTime": "2020-09-22T07:44:45.000Z","localModificationTime": "2020-09-22T07:44:45.000Z"},{"type": "file","inode": "xxxx1","name": "bmw.pdf","creationTime": "2021-08-17T13:19:07.000Z","modificationTime": "2021-08-17T13:19:07.000Z","contentType": "application/pdf","size": "241674","eTag": "\\"030ca96f0af3b3d3cfbf31c2be3129d6\\"","isFavorite": false,"crc64": "12098979488941977387","metaData": {"x-smh-meta-creation-date": "Tue, 17 Aug 2021 13:19:06 GMT"},"path": ["abc", "bmw.pdf"],"userId": "12","localCreationTime": "2020-09-22T07:44:45.000Z","localModificationTime": "2020-09-22T07:44:45.000Z"},{"type": "dir","inode": "xxx999","name": "fysn","creationTime": "2021-08-20T10:01:40.000Z","modificationTime": "2021-08-21T07:30:25.000Z","path": ["fysn"],"userId": "12","isFavorite": false},{"type": "file","inode": "xxbb","name": "智能媒资托管-144px (1).png","creationTime": "2021-08-20T09:59:25.000Z","modificationTime": "2021-08-20T09:59:25.000Z","contentType": "image/png","size": "7199","eTag": "\\"7d9ce6ef46c00d3924702b7b4224d029\\"","isFavorite": true,"crc64": "13076174829147183381","metaData": {"x-smh-meta-creation-date": "Fri, 20 Aug 2021 09:59:22 GMT"},"path": ["fysn", "智能媒资托管-144px (1).png"],"previewByDoc": true,"previewByCI": true,"previewAsIcon": true,"fileType": "powerpoint","userId": "12","localCreationTime": "2020-09-22T07:44:45.000Z","localModificationTime": "2020-09-22T07:44:45.000Z"}/* ... */]}
响应体字段说明:
响应参数 | 描述 | 类型 |
searchId | 搜索任务 ID,用于异步获取搜索结果 | String |
searchFinished | 搜索是否已完成 | Boolean |
hasMore | 是否有更多搜索结果 | Boolean |
nextMarker | 用于获取后续页的分页标识,仅当 hasMore 为 true 时才返回该字段 | Int |
contents | 第一页搜索结果,可能为空数组,有关异步搜索的说明请参阅【接口说明】 | Int |
contents中包含以下内容:
响应参数 | 描述 | 类型 |
type | 条目类型,支持以下类型: dir: 目录或相簿;file: 文件,仅用于文件类型媒体库;image: 图片,仅用于媒体类型媒体库;video: 视频,仅用于媒体类型媒体库;symlink: 符号链接; | String |
inode | 文件目录ID | String |
name | 目录或相簿名或文件名 | Boolean |
creationTime | ISO 8601格式的日期与时间字符串,表示目录或相簿的创建时间或文件的上传时间,例如:2020-10-14T10:17:57.953Z | String |
modificationTime | 文件最近一次被覆盖的时间,或者目录内最近一次增删子目录或文件的时间 | String |
contentType | 媒体类型 | String |
versionId | 版本号 | String |
size | 文件大小,为了避免数字精度问题,这里为字符串格式 | String |
isFavorite | 布尔值,是否被收藏,当 WithFavoriteStatus = 1 时返回 | Boolean |
eTag | 文件 ETag | String |
crc64 | 文件的 CRC64-ECMA182 校验值,为了避免数字精度问题,这里为字符串格式 | String |
metaData | 文件元数据信息 | Object |
path | 当前项目所在的目录,包含当前项目的 name | String |
userId | 创建/更新者 用户 ID | String |
previewByDoc | 是否可通过 wps 预览 | Boolean |
previewByCI | 是否可通过万象预览 | Boolean |
previewAsIcon | 是否可使用预览图当做 icon | Boolean |
fileType | 文件类型:excel、powerpoint 等 | String |
labels | 简易文件标签 | String Array |
category | 自定义文件分类,比如image、video、doc等 | String |
localCreationTime | 文件对应的本地创建时间 | String |
localModificationTime | 文件对应的本地修改时间 | String |
sensitiveWordAuditStatus | 敏感文本审核状态,包含0、1两种状态: 0:不开启 1:开启 | Int |
spaceId | 空间id | String |
userOrgId | 用户原id | String |
spaceTag | 空间标签 | String |
modifierName | 修改者名称 | String |
highlight | 强调 | String |
authorityList | 权限列表 | Array |
authorityButtonList | 按钮权限列表 | Array |
authorityList包含以下参数:
响应参数 | 描述 | 类型 |
canView | 是否可查看 | Boolean |
canPreview | 是否可预览 | Boolean |
canDownload | 是否可下载 | Boolean |
canPrint | 是否可打印 | Boolean |
canUpload | 是否可上传 | Boolean |
canDelete | 是否可删除 | Boolean |
canModify | 是否可编辑 | Boolean |
canAuthorize | 是否可授权 | Boolean |
canShare | 是否可分享 | Boolean |
canPreviewSelf | 是否可自预览 | Boolean |
canDownloadSelf | 是否可自下载 | Boolean |
authorityButtonList包含以下参数:
响应参数 | 描述 | 类型 |
showViewButton | 是否展示查看按钮 | Boolean |
showPreviewButton | 是否展示预览按钮 | Boolean |
showDownloadButton | 是否展示下载按钮 | Boolean |
showUploadButton | 是否展示上传按钮 | Boolean |
showDeleteButton | 是否展示删除按钮 | Boolean |
showAuthorizeButton | 是否展示授权按钮 | Boolean |
showShareButton | 是否展示分享按钮 | Boolean |
showModifyButton | 是否展示编辑按钮 | Boolean |
showMoveButton | 是否展示移动按钮 | Boolean |
showRenameButton | 是否展示重命名按钮 | Boolean |
showCopyButton | 是否展示复制按钮 | Boolean |
showRestoreButton | 是否展示恢复按钮 | Boolean |