搜索接口
更新时间:2024-07-25
Method:post
Path:/kmss/openapi/mpks/api/search
接口描述: 通用搜索接口
请求参数
名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
query | string | 是 | 检索query,不允许为空字符串 |
logId | string | 除了翻页,其他检索不要加logId,不填会自动补充 | |
pn | Integer | 是 | 页码,从1开始编码 |
ps | Integer | 是 | pagesize,每页页面条数,默认不填20 |
sort | string | 是 | 排序方式默认相关性:relevance。按时间排序:time。 时间排序:按照召回的topn进行分段,在分段内进行时间倒排,避免相关性较差但时间较新的数据排到前面。 相关性排序:用语义大模型计算query和结果的相关性,根据相关性得分进行整体的排序 |
seaerchType | string | 是 | 检索类型,正常为 normal,高级检索为advanced |
kpType | array |
知识点类型检索:para/video/image/audio/web/wiki/entity/faq/file | |
rankType | string | 精排类型,不传默认为general,可选值:1.norank 不精排2.general 通用精排模型3.nlp 使用nlp排序模型 | |
recallType | string | 召回类型,不传默认为general,general 通用召回,mrc 问答段落召回 | |
repoGuid | string | 知识库id | |
categoryIds | array |
分类浏览ids | |
--item | Integer | 分类浏览id | |
timeFilter | object | 时间范围过滤,为空表示不进行时间过滤,begin和end为unix时间戳。时间筛选是根据数据中的updateTime字段进行过滤 | |
-begin | Integer | ||
-end | Integer | ||
tagFilter | array |
标签过滤,为空表示不进行标签过滤 | |
--item | string | 标签 | |
wikiDocTypeFilter | array |
知识库新版结果类型过滤 word文档:101 excel文档:4 pdf文档:102 ppt文档:6 视频 :103 音频:105 轻文档:1,3 知识本:2 知识库:-1 | |
--item | Integer | 结果类型 | |
needCorrect | boolean | 是否需要纠错,不需要则按照输入的query进行检索,需要则根据da返回的纠错query以及置信度进行检索(显示看接口响应的escoreType&rewriteQuery),默认需要 | |
needUserRight | boolean | 是否需要用户权限检索,默认需要 | |
needAnn | boolean | 是否需要ann召回,语义检索能力,默认是true | |
needCollapse | boolean | 是否需要段落按照docId合并,不传默认为true | |
needHighlight | boolean | 是否需要高亮,不传默认为true | |
matchFields | array |
参与召回的字段名,默认为title&content | |
--item | string | 字段名,标题为title,正文为content,单独字段召回默认无精排 | |
filterQuerys | array object | 额外的过滤筛选条件 | |
--item | object | ||
-- --field | string | 生效的field,field.keyword为完整匹配 | |
-- --values | array |
需要过滤的值 |
数据类型 | 文件-段落 | 视频-段落 | 音频-段落 | 百科 | faq | 文件 | 文件-视频 | 文件-音频 | 结构化(2.2.0) |
---|---|---|---|---|---|---|---|---|---|
kptype | para | video | audio | wiki | faq | file | video_file | audio_file | struct |
Plain Text
1请求参数示例
2{
3 "query": "测试",
4 "timeFilter": {},
5 "sort": "relevance",
6 "pn": 1,
7 "ps": 10,
8 "searchType": "normal",
9 "needCorrect": false,
10 "inputQuery": "皮卡丘",
11 "kpType": [
12 "file",
13 "para"
14 ],
15 "needCollapse": true,
16 "needHighlight": false,
17 "rankType": "nlp",
18 "recallType": "mrc",
19 "matchFields": [
20 "title"
21 ],
22 "filterQuerys": [
23 {
24 "field": "@type",
25 "values": [
26 "打点",
27 "在线"
28 ]
29 },
30 {
31 "field": "docId",
32 "values": [
33 "1",
34 "2"
35 ]
36 }
37 ],
38 "wikiDocTypeFilter": [
39 103,
40 -1
41 ],
42 "needUserRight": false
43}
返回数据
名称 | 类型 | 说明 |
---|---|---|
errno | integer | 错误码,正常为0 |
msg | string | 错误信息 |
data | object | 返回的检索数据 |
--total | integer | 数据总条数 |
--pagingTotal | integer | 分页使用的条数 |
--query | string | |
--logId | string | 后端返回的检索的logId |
--rewriteQuery | string | 纠错后的query |
--escoreType | integer | 置信度 0:无置信度,前端不处理,1:低置信度,前端显示‘您要找的是不是: ${rewriteQuery[0]}’,2:高置信度,前端显示‘目前为您显示的是以下字词的搜索结果:${rewriteQuery[0]}, 仍然搜索 ${query}' 1.搜索结果按原query召回 ; 2.搜索结果按纠错后的query召回 |
--tagList | array object | 标签过滤筛选项 |
--classesTree | array object | 类别过滤筛选项 |
--aggResult | array object | 来源过滤筛选项 |
--results | array object | 返回的搜索结果集合 |
-- --title | string | 标题 |
-- --abstract | string | 摘要 |
-- --url | string | 预览地址 |
-- --downloadUrl | string | 下载地址 |
-- --repoGuid | string | 所属知识库id |
-- --repoName | string | 所属知识库名称 |
-- --docId | string | 对应当前检索召回的段落id所属的文档id |
-- --nid | string | 对应当前检索召回的段落id |
-- --updateTime | long | 文档本身的时间 |
-- --..... | 其他物料相关字段 | |
--rightRecommends | object | 右侧推荐(无用) |
--aggregations | object | 自定义聚合(无用) |
--recallNidList | array |
recallType为mrc时返回,问答所需 |
Plain Text
1返回示例
2{
3 "errno": 0,
4 "msg": "",
5 "data": {
6 "total": 5,
7 "pagingTotal": 5,
8 "query": "测试",
9 "results": [
10 {
11 "@type": "文档",
12 "analysisDocs": {
13 "attachments": [],
14 "codeBlocks": [],
15 "contactUser": [],
16 "links": []
17 },
18 "attachInfos": [],
19 "attachments": [],
20 "breadcrumb": "/我的测试文档",
21 "cluster_codes": [],
22 "cms_online": 1,
23 "code": 1,
24 "createBy": "7eb0a1afa7714c38b209d058a968e594",
25 "createTime": 1705832339000,
26 "docCatalogue": [],
27 "docGuid": "CzC87gCBL4Rpfx",
28 "docId": "CzC87gCBL4Rpfx",
29 "docType": "",
30 "downloadUrl": "/data/file/download?path=z12XtCSOC0%2FqGaCOTpgrx%2FCzC87gCBL4Rpfx.wiki",
31 "editors": [
32 "7eb0a1afa7714c38b209d058a968e594@default.com"
33 ],
34 "fileName": "我的测试文档.wiki",
35 "filePath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/CzC87gCBL4Rpfx.wiki",
36 "groupGuid": "pKzJfZczuc",
37 "htmlContent": "",
38 "htmlPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/CzC87gCBL4Rpfx.html",
39 "id": "66f7d9610e56ce3d0ab8a9d2484dcfa9",
40 "isPubToHome": 0,
41 "isPubToKS": 0,
42 "isUpsert": false,
43 "jsonPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/CzC87gCBL4Rpfx.json",
44 "links": [],
45 "markdel_bool": false,
46 "nid": "CzC87gCBL4Rpfx_text_0",
47 "nodeId": 3,
48 "oriId": 52,
49 "paras_count": 2,
50 "publishTime": 0,
51 "qc_bool": false,
52 "relevance_score": "0.414204",
53 "repoCatalogue": [],
54 "repoGuid": "qGaCOTpgrx",
55 "repoName": "huinuanhan",
56 "repoScope": 20,
57 "repoType": 1,
58 "scope": 20,
59 "size": 465,
60 "spaceGuid": "z12XtCSOC0",
61 "status": 40,
62 "title": "我的<em>测试</em>文档",
63 "updateBy": "7eb0a1afa7714c38b209d058a968e594",
64 "updateTime": 1705832346000,
65 "update_content": true,
66 "url": "https://njjs.qasandbox.bce.baidu.com/knowledge/z12XtCSOC0/pKzJfZczuc/qGaCOTpgrx/CzC87gCBL4Rpfx",
67 "wikiDocType": 1,
68 "wikiUrl": "",
69 "para": "我的测试文档 测试一下 北京的天气特别好,今天是晴天",
70 "position_information": "{\"block_text\": [], \"box\": [], \"page_num\": [], \"page_size\": []}",
71 "show_fields": [],
72 "abstract": "我的<em>测试</em>文档 <em>测试</em>一下 北京的天气特别好,今天是晴天",
73 "tpl": "doc",
74 "srcName": "知识库同步节点",
75 "srcid": "1003",
76 "type": "MIXED"
77 },
78 {
79 "@type": "文档",
80 "analysisDocs": {
81 "attachments": [],
82 "codeBlocks": [],
83 "contactUser": [],
84 "links": []
85 },
86 "attachInfos": [],
87 "attachments": [],
88 "breadcrumb": "/测试文档",
89 "cluster_codes": [],
90 "cms_online": 1,
91 "code": 1,
92 "createBy": "7eb0a1afa7714c38b209d058a968e594",
93 "createTime": 1705834024000,
94 "docCatalogue": [],
95 "docGuid": "wpgjZTN0Y-ioEY",
96 "docId": "wpgjZTN0Y-ioEY",
97 "docType": "",
98 "downloadUrl": "/data/file/download?path=z12XtCSOC0%2FqGaCOTpgrx%2FwpgjZTN0Y-ioEY.wiki",
99 "editors": [
100 "7eb0a1afa7714c38b209d058a968e594@default.com"
101 ],
102 "fileName": "测试文档.wiki",
103 "filePath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/wpgjZTN0Y-ioEY.wiki",
104 "groupGuid": "pKzJfZczuc",
105 "htmlContent": "",
106 "htmlPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/wpgjZTN0Y-ioEY.html",
107 "id": "1e7daefe0234e9cc93f6cecb5822711c",
108 "isPubToHome": 0,
109 "isPubToKS": 0,
110 "isUpsert": false,
111 "jsonPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/wpgjZTN0Y-ioEY.json",
112 "links": [],
113 "nid": "wpgjZTN0Y-ioEY_text_0",
114 "nodeId": 3,
115 "oriId": 53,
116 "para_type": "text",
117 "paras_count": 2,
118 "publishTime": 0,
119 "qc_bool": false,
120 "relevance_score": "0.317094",
121 "repoCatalogue": [],
122 "repoGuid": "qGaCOTpgrx",
123 "repoName": "huinuanhan",
124 "repoScope": 20,
125 "repoType": 1,
126 "scope": 20,
127 "size": 360,
128 "spaceGuid": "z12XtCSOC0",
129 "status": 40,
130 "title": "<em>测试</em>文档",
131 "updateBy": "7eb0a1afa7714c38b209d058a968e594",
132 "updateTime": 1705915265000,
133 "url": "https://njjs.qasandbox.bce.baidu.com/wiki_static/knowledge/z12XtCSOC0/pKzJfZczuc/qGaCOTpgrx/wpgjZTN0Y-ioEY",
134 "wikiDocType": 1,
135 "wikiUrl": "",
136 "para": "测试文档 呜呜呜呜呜呜呜",
137 "position_information": "{\"block_text\": [], \"box\": [], \"page_num\": [], \"page_size\": []}",
138 "show_fields": [],
139 "abstract": "<em>测试</em>文档 呜呜呜呜呜呜呜",
140 "tpl": "doc",
141 "srcName": "知识库同步节点",
142 "srcid": "1003",
143 "type": "MIXED"
144 },
145 {
146 "@type": "文档",
147 "analysisDocs": {
148 "attachments": [],
149 "codeBlocks": [],
150 "contactUser": [],
151 "links": []
152 },
153 "attachInfos": [],
154 "attachments": [],
155 "breadcrumb": "/测试文档/测试文档2",
156 "cluster_codes": [],
157 "cms_online": 1,
158 "code": 1,
159 "createBy": "7eb0a1afa7714c38b209d058a968e594",
160 "createTime": 1705915287000,
161 "docCatalogue": [],
162 "docGuid": "A0Pg3Xi7LNOPtu",
163 "docId": "A0Pg3Xi7LNOPtu",
164 "docType": "",
165 "downloadUrl": "/data/file/download?path=z12XtCSOC0%2FqGaCOTpgrx%2FA0Pg3Xi7LNOPtu.wiki",
166 "editors": [
167 "7eb0a1afa7714c38b209d058a968e594@default.com"
168 ],
169 "fileName": "测试文档2.wiki",
170 "filePath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/A0Pg3Xi7LNOPtu.wiki",
171 "groupGuid": "pKzJfZczuc",
172 "htmlContent": "",
173 "htmlPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/A0Pg3Xi7LNOPtu.html",
174 "id": "e36177f996585b41e858e1219ca5b088",
175 "isPubToHome": 0,
176 "isPubToKS": 0,
177 "isUpsert": false,
178 "jsonPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/A0Pg3Xi7LNOPtu.json",
179 "links": [],
180 "nid": "A0Pg3Xi7LNOPtu_text_0",
181 "nodeId": 3,
182 "oriId": 84,
183 "para_type": "text",
184 "paras_count": 2,
185 "publishTime": 0,
186 "qc_bool": false,
187 "relevance_score": "0.316932",
188 "repoCatalogue": [
189 {
190 "childCount": 1,
191 "id": "wpgjZTN0Y-ioEY",
192 "level": 1,
193 "title": "测试文档"
194 }
195 ],
196 "repoGuid": "qGaCOTpgrx",
197 "repoName": "huinuanhan",
198 "repoScope": 20,
199 "repoType": 1,
200 "scope": 20,
201 "size": 358,
202 "spaceGuid": "z12XtCSOC0",
203 "status": 40,
204 "title": "<em>测试</em>文档2",
205 "updateBy": "7eb0a1afa7714c38b209d058a968e594",
206 "updateTime": 1705915288000,
207 "url": "https://njjs.qasandbox.bce.baidu.com/wiki_static/knowledge/z12XtCSOC0/pKzJfZczuc/qGaCOTpgrx/A0Pg3Xi7LNOPtu",
208 "wikiDocType": 1,
209 "wikiUrl": "",
210 "para": "测试文档2 呃呃呃呃呃呃",
211 "position_information": "{\"block_text\": [], \"box\": [], \"page_num\": [], \"page_size\": []}",
212 "show_fields": [],
213 "abstract": "<em>测试</em>文档2 呃呃呃呃呃呃",
214 "tpl": "doc",
215 "srcName": "知识库同步节点",
216 "srcid": "1003",
217 "type": "MIXED"
218 },
219 {
220 "@type": "文档",
221 "analysisDocs": {
222 "attachments": [],
223 "codeBlocks": [],
224 "contactUser": [],
225 "links": []
226 },
227 "attachInfos": [],
228 "attachments": [],
229 "breadcrumb": "/测试文档/测试文档2/测试文档4",
230 "cluster_codes": [],
231 "cms_online": 1,
232 "code": 1,
233 "createBy": "7eb0a1afa7714c38b209d058a968e594",
234 "createTime": 1705915327000,
235 "docCatalogue": [],
236 "docGuid": "SCiriJu9uXnkbK",
237 "docId": "SCiriJu9uXnkbK",
238 "docType": "",
239 "downloadUrl": "/data/file/download?path=z12XtCSOC0%2FqGaCOTpgrx%2FSCiriJu9uXnkbK.wiki",
240 "editors": [
241 "7eb0a1afa7714c38b209d058a968e594@default.com"
242 ],
243 "fileName": "测试文档4.wiki",
244 "filePath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/SCiriJu9uXnkbK.wiki",
245 "groupGuid": "pKzJfZczuc",
246 "htmlContent": "",
247 "htmlPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/SCiriJu9uXnkbK.html",
248 "id": "a94760af263dbb5fbd54520fc94e3a7e",
249 "isPubToHome": 0,
250 "isPubToKS": 0,
251 "isUpsert": false,
252 "jsonPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/SCiriJu9uXnkbK.json",
253 "links": [],
254 "nid": "SCiriJu9uXnkbK_text_0",
255 "nodeId": 3,
256 "oriId": 86,
257 "para_type": "text",
258 "paras_count": 2,
259 "publishTime": 0,
260 "qc_bool": false,
261 "relevance_score": "0.296494",
262 "repoCatalogue": [
263 {
264 "childCount": 1,
265 "id": "wpgjZTN0Y-ioEY",
266 "level": 1,
267 "title": "测试文档"
268 },
269 {
270 "childCount": 1,
271 "id": "A0Pg3Xi7LNOPtu",
272 "level": 2,
273 "title": "测试文档2"
274 }
275 ],
276 "repoGuid": "qGaCOTpgrx",
277 "repoName": "huinuanhan",
278 "repoScope": 20,
279 "repoType": 1,
280 "scope": 20,
281 "size": 367,
282 "spaceGuid": "z12XtCSOC0",
283 "status": 40,
284 "title": "<em>测试</em>文档4",
285 "updateBy": "7eb0a1afa7714c38b209d058a968e594",
286 "updateTime": 1705915328000,
287 "url": "https://njjs.qasandbox.bce.baidu.com/wiki_static/knowledge/z12XtCSOC0/pKzJfZczuc/qGaCOTpgrx/SCiriJu9uXnkbK",
288 "wikiDocType": 1,
289 "wikiUrl": "",
290 "para": "测试文档4 咋啊啊啊啊啊啊啊啊",
291 "position_information": "{\"block_text\": [], \"box\": [], \"page_num\": [], \"page_size\": []}",
292 "show_fields": [],
293 "abstract": "<em>测试</em>文档4 咋啊啊啊啊啊啊啊啊",
294 "tpl": "doc",
295 "srcName": "知识库同步节点",
296 "srcid": "1003",
297 "type": "MIXED"
298 },
299 {
300 "@type": "文档",
301 "analysisDocs": {
302 "attachments": [],
303 "codeBlocks": [],
304 "contactUser": [],
305 "links": []
306 },
307 "attachInfos": [],
308 "attachments": [],
309 "breadcrumb": "/测试文档/测试文档2/测试文档3",
310 "cluster_codes": [],
311 "cms_online": 1,
312 "code": 1,
313 "createBy": "7eb0a1afa7714c38b209d058a968e594",
314 "createTime": 1705915316000,
315 "docCatalogue": [],
316 "docGuid": "7mi0zGE2CSdku1",
317 "docId": "7mi0zGE2CSdku1",
318 "docType": "",
319 "downloadUrl": "/data/file/download?path=z12XtCSOC0%2FqGaCOTpgrx%2F7mi0zGE2CSdku1.wiki",
320 "editors": [
321 "7eb0a1afa7714c38b209d058a968e594@default.com"
322 ],
323 "fileName": "测试文档3.wiki",
324 "filePath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/7mi0zGE2CSdku1.wiki",
325 "groupGuid": "pKzJfZczuc",
326 "htmlContent": "",
327 "htmlPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/7mi0zGE2CSdku1.html",
328 "id": "99dd9efd1d78486dc6ef4bc186e95ae2",
329 "isPubToHome": 0,
330 "isPubToKS": 0,
331 "isUpsert": false,
332 "jsonPath": "/ceph/data/kmss/z12XtCSOC0/qGaCOTpgrx/7mi0zGE2CSdku1.json",
333 "links": [],
334 "nid": "7mi0zGE2CSdku1_text_0",
335 "nodeId": 3,
336 "oriId": 85,
337 "para_type": "text",
338 "paras_count": 2,
339 "publishTime": 0,
340 "qc_bool": false,
341 "relevance_score": "0.170829",
342 "repoCatalogue": [
343 {
344 "childCount": 1,
345 "id": "wpgjZTN0Y-ioEY",
346 "level": 1,
347 "title": "测试文档"
348 },
349 {
350 "childCount": 1,
351 "id": "A0Pg3Xi7LNOPtu",
352 "level": 2,
353 "title": "测试文档2"
354 }
355 ],
356 "repoGuid": "qGaCOTpgrx",
357 "repoName": "huinuanhan",
358 "repoScope": 20,
359 "repoType": 1,
360 "scope": 20,
361 "size": 363,
362 "spaceGuid": "z12XtCSOC0",
363 "status": 40,
364 "title": "<em>测试</em>文档3",
365 "updateBy": "7eb0a1afa7714c38b209d058a968e594",
366 "updateTime": 1705915306000,
367 "url": "https://njjs.qasandbox.bce.baidu.com/wiki_static/knowledge/z12XtCSOC0/pKzJfZczuc/qGaCOTpgrx/7mi0zGE2CSdku1",
368 "wikiDocType": 1,
369 "wikiUrl": "",
370 "para": "测试文档3 吞吞吐吐吞吞吐吐",
371 "position_information": "{\"block_text\": [], \"box\": [], \"page_num\": [], \"page_size\": []}",
372 "show_fields": [],
373 "abstract": "<em>测试</em>文档3 吞吞吐吐吞吞吐吐",
374 "tpl": "doc",
375 "srcName": "知识库同步节点",
376 "srcid": "1003",
377 "type": "MIXED"
378 }
379 ],
380 "logId": "7832422223732816237",
381 "rightRecommends": {},
382 "tagList": null,
383 "aggResult": {
384 "id": 1,
385 "name": "根节点",
386 "count": 5,
387 "children": [
388 {
389 "id": 3,
390 "name": "知识库同步节点",
391 "count": 5,
392 "children": null
393 }
394 ]
395 },
396 "aggregations": null,
397 "rewriteQuery": null,
398 "escoreType": 0,
399 "classesTree": null,
400 "recallNidList": [
401 "c0eb5cb77d8024b6_1002_1fffeca69dd0c0452baf8015e63126f2_text_1",
402 "c0eb5cb77d8024b6_1002_1fffeca69dd0c0452baf8015e63126f2_text_0",
403 "c0eb5cb77d8024b6_1002_1fffeca69dd0c0452baf8015e63126f2_-1",
404 "c0eb5cb77d8024b6_1002_226fdca1b992df47b8ab3cf426d476e7_text_1",
405 "c0eb5cb77d8024b6_1002_226fdca1b992df47b8ab3cf426d476e7_text_0",
406 "c0eb5cb77d8024b6_1002_226fdca1b992df47b8ab3cf426d476e7_text_2",
407 "c0eb5cb77d8024b6_1002_226fdca1b992df47b8ab3cf426d476e7_text_3",
408 "c0eb5cb77d8024b6_1002_226fdca1b992df47b8ab3cf426d476e7_-1"
409 ]
410 }
411}