v3-search.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-search.yaml
  2. get:
  3. summary: 全文检索
  4. tags:
  5. - search
  6. operationId: get_api_v3_search
  7. description: |-
  8. 底层走 OpenSearch。同样的参数也可以用 `POST /v3/search` 放在请求体里提交。
  9. 翻页深度受 OpenSearch 限制:`page × per_page` 不能超过 10000,超出 422。
  10. 搜索服务连不上或超时回 503(`search-unavailable`)。
  11. 实现:`V3\SearchController@index`
  12. security:
  13. - { }
  14. -
  15. bearerAuth: []
  16. parameters:
  17. -
  18. name: q
  19. in: query
  20. schema:
  21. type: string
  22. description: 检索词
  23. required: true
  24. -
  25. name: search_mode
  26. in: query
  27. schema:
  28. type: string
  29. enum:
  30. - fuzzy
  31. - exact
  32. - semantic
  33. - hybrid
  34. - definition
  35. default: fuzzy
  36. description: '检索模式:fuzzy 多词模糊(默认)、exact 词形精确、semantic 语义向量、hybrid 模糊 + 语义、definition 黑体定义优先'
  37. -
  38. name: resource_type
  39. in: query
  40. schema:
  41. type: string
  42. enum:
  43. - tipitaka
  44. - original_text
  45. - term
  46. description: '资源类型:tipitaka 三藏(段落与整章)、original_text 原文分段、term 术语'
  47. -
  48. name: resource_id
  49. in: query
  50. schema:
  51. type: string
  52. description: '限定某个资源 id'
  53. -
  54. name: granularity
  55. in: query
  56. schema:
  57. type: string
  58. enum:
  59. - book
  60. - chapter
  61. - session
  62. - paragraph
  63. description: 文档颗粒度
  64. -
  65. name: language
  66. in: query
  67. schema:
  68. type: string
  69. description: '文档语言,如 pi、zh、en'
  70. -
  71. name: category
  72. in: query
  73. schema:
  74. type: string
  75. description: 分类,逗号分隔,须全部命中
  76. example: 'sutta,mūla'
  77. -
  78. name: tags
  79. in: query
  80. schema:
  81. type: string
  82. description: 标签,逗号分隔,命中任一
  83. -
  84. name: page_refs
  85. in: query
  86. schema:
  87. type: array
  88. description: 页码标记,命中任一
  89. example:
  90. - V3.81
  91. - M3.58
  92. -
  93. name: related_id
  94. in: query
  95. schema:
  96. type: array
  97. description: '关联 id(经文段落是 `{book}-{para}`),命中任一'
  98. example:
  99. - 93-5
  100. -
  101. name: author
  102. in: query
  103. schema:
  104. type: string
  105. description: 作者或译者
  106. -
  107. name: channel
  108. in: query
  109. schema:
  110. type: string
  111. description: '来源 channel 的 uuid'
  112. -
  113. name: facets
  114. in: query
  115. schema:
  116. type: boolean
  117. default: false
  118. description: '是否在 `meta.facets` 里返回按 resource_type / language / category / granularity 的分面计数'
  119. -
  120. name: page
  121. in: query
  122. schema:
  123. type: integer
  124. default: 1
  125. description: 页码
  126. -
  127. name: per_page
  128. in: query
  129. schema:
  130. type: integer
  131. default: 20
  132. description: '每页条数,上限 100'
  133. responses:
  134. 200:
  135. description: 成功
  136. content:
  137. application/json:
  138. schema:
  139. type: object
  140. properties:
  141. data:
  142. type: array
  143. items:
  144. type: object
  145. properties:
  146. id:
  147. type: string
  148. resource_type:
  149. type: string
  150. resource_id:
  151. type: string
  152. nullable: true
  153. granularity:
  154. type: string
  155. nullable: true
  156. language:
  157. type: string
  158. nullable: true
  159. related_id:
  160. type: string
  161. nullable: true
  162. score:
  163. type: number
  164. nullable: true
  165. title:
  166. type: string
  167. content:
  168. type: string
  169. highlight:
  170. type: string
  171. nullable: true
  172. bold:
  173. type: array
  174. items: { type: string }
  175. path:
  176. type: string
  177. nullable: true
  178. category:
  179. type: array
  180. items: { type: string }
  181. tags:
  182. type: array
  183. items: { type: string }
  184. updated_at:
  185. type: string
  186. nullable: true
  187. display:
  188. type: string
  189. description: 仅在部分查询口径下返回。
  190. meta:
  191. type: object
  192. properties:
  193. current_page:
  194. type: integer
  195. description: 当前页
  196. per_page:
  197. type: integer
  198. description: 每页条数
  199. total:
  200. type: integer
  201. description: '命中总数(total_relation 为 gte 时是下限)'
  202. total_relation:
  203. type: string
  204. description: 'eq 精确,gte 表示「至少这么多」(OpenSearch 只精确计数到 10000)'
  205. last_page:
  206. type: integer
  207. description: 最后一页(受翻页深度限制)
  208. facets:
  209. type: object
  210. description: '分面计数,只在 facets=true 时出现。键是 resource_type / language / category / granularity'
  211. additionalProperties:
  212. type: array
  213. items: { type: object, required: [key, count], properties: { key: { type: string }, count: { type: integer } } }
  214. 422:
  215. $ref: '../../main.yaml#/components/responses/ProblemValidation'
  216. 503:
  217. description: 搜索服务暂不可用
  218. content:
  219. application/problem+json:
  220. schema:
  221. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  222. post:
  223. summary: 全文检索(POST)
  224. tags:
  225. - search
  226. operationId: post_api_v3_search
  227. description: |-
  228. 与 `GET /v3/search` 完全等价,参数放在 JSON 请求体里(数组参数多、URL 放不下时用)。
  229. 实现:`V3\SearchController@store`
  230. security:
  231. - { }
  232. -
  233. bearerAuth: []
  234. requestBody:
  235. required: true
  236. content:
  237. application/json:
  238. schema:
  239. type: object
  240. properties:
  241. q:
  242. type: string
  243. description: 检索词
  244. search_mode:
  245. type: string
  246. description: 检索模式
  247. enum:
  248. - fuzzy
  249. - exact
  250. - semantic
  251. - hybrid
  252. - definition
  253. default: fuzzy
  254. resource_type:
  255. type: string
  256. description: 资源类型
  257. enum:
  258. - tipitaka
  259. - original_text
  260. - term
  261. resource_id:
  262. type: string
  263. description: '限定某个资源 id'
  264. granularity:
  265. type: string
  266. description: 文档颗粒度
  267. enum:
  268. - book
  269. - chapter
  270. - session
  271. - paragraph
  272. language:
  273. type: string
  274. description: 文档语言
  275. category:
  276. type: string
  277. description: 分类,逗号分隔,须全部命中
  278. tags:
  279. type: string
  280. description: 标签,逗号分隔,命中任一
  281. page_refs:
  282. type: array
  283. description: 页码标记,命中任一
  284. related_id:
  285. type: array
  286. description: '关联 id,命中任一'
  287. author:
  288. type: string
  289. description: 作者或译者
  290. channel:
  291. type: string
  292. description: '来源 channel 的 uuid'
  293. facets:
  294. type: boolean
  295. description: 是否返回分面计数
  296. default: false
  297. page:
  298. type: integer
  299. description: 页码
  300. default: 1
  301. per_page:
  302. type: integer
  303. description: '每页条数,上限 100'
  304. default: 20
  305. required:
  306. - q
  307. responses:
  308. 200:
  309. description: 成功
  310. content:
  311. application/json:
  312. schema:
  313. type: object
  314. properties:
  315. data:
  316. type: array
  317. items:
  318. type: object
  319. properties:
  320. id:
  321. type: string
  322. resource_type:
  323. type: string
  324. resource_id:
  325. type: string
  326. nullable: true
  327. granularity:
  328. type: string
  329. nullable: true
  330. language:
  331. type: string
  332. nullable: true
  333. related_id:
  334. type: string
  335. nullable: true
  336. score:
  337. type: number
  338. nullable: true
  339. title:
  340. type: string
  341. content:
  342. type: string
  343. highlight:
  344. type: string
  345. nullable: true
  346. bold:
  347. type: array
  348. items: { type: string }
  349. path:
  350. type: string
  351. nullable: true
  352. category:
  353. type: array
  354. items: { type: string }
  355. tags:
  356. type: array
  357. items: { type: string }
  358. updated_at:
  359. type: string
  360. nullable: true
  361. display:
  362. type: string
  363. description: 仅在部分查询口径下返回。
  364. meta:
  365. type: object
  366. properties:
  367. current_page:
  368. type: integer
  369. description: 当前页
  370. per_page:
  371. type: integer
  372. description: 每页条数
  373. total:
  374. type: integer
  375. description: '命中总数(total_relation 为 gte 时是下限)'
  376. total_relation:
  377. type: string
  378. description: 'eq 精确,gte 表示「至少这么多」'
  379. last_page:
  380. type: integer
  381. description: 最后一页(受翻页深度限制)
  382. facets:
  383. type: object
  384. description: '分面计数,只在 facets=true 时出现。键是 resource_type / language / category / granularity'
  385. additionalProperties:
  386. type: array
  387. items: { type: object, required: [key, count], properties: { key: { type: string }, count: { type: integer } } }
  388. 422:
  389. $ref: '../../main.yaml#/components/responses/ProblemValidation'
  390. 503:
  391. description: 搜索服务暂不可用
  392. content:
  393. application/problem+json:
  394. schema:
  395. $ref: '../../main.yaml#/components/schemas/ProblemDetails'