| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-search.yaml
- get:
- summary: 全文检索
- tags:
- - search
- operationId: get_api_v3_search
- description: |-
- 底层走 OpenSearch。同样的参数也可以用 `POST /v3/search` 放在请求体里提交。
- 翻页深度受 OpenSearch 限制:`page × per_page` 不能超过 10000,超出 422。
- 搜索服务连不上或超时回 503(`search-unavailable`)。
- 实现:`V3\SearchController@index`
- security:
- - { }
- -
- bearerAuth: []
- parameters:
- -
- name: q
- in: query
- schema:
- type: string
- description: 检索词
- required: true
- -
- name: search_mode
- in: query
- schema:
- type: string
- enum:
- - fuzzy
- - exact
- - semantic
- - hybrid
- - definition
- default: fuzzy
- description: '检索模式:fuzzy 多词模糊(默认)、exact 词形精确、semantic 语义向量、hybrid 模糊 + 语义、definition 黑体定义优先'
- -
- name: resource_type
- in: query
- schema:
- type: string
- enum:
- - tipitaka
- - original_text
- - term
- description: '资源类型:tipitaka 三藏(段落与整章)、original_text 原文分段、term 术语'
- -
- name: resource_id
- in: query
- schema:
- type: string
- description: '限定某个资源 id'
- -
- name: granularity
- in: query
- schema:
- type: string
- enum:
- - book
- - chapter
- - session
- - paragraph
- description: 文档颗粒度
- -
- name: language
- in: query
- schema:
- type: string
- description: '文档语言,如 pi、zh、en'
- -
- name: category
- in: query
- schema:
- type: string
- description: 分类,逗号分隔,须全部命中
- example: 'sutta,mūla'
- -
- name: tags
- in: query
- schema:
- type: string
- description: 标签,逗号分隔,命中任一
- -
- name: page_refs
- in: query
- schema:
- type: array
- description: 页码标记,命中任一
- example:
- - V3.81
- - M3.58
- -
- name: related_id
- in: query
- schema:
- type: array
- description: '关联 id(经文段落是 `{book}-{para}`),命中任一'
- example:
- - 93-5
- -
- name: author
- in: query
- schema:
- type: string
- description: 作者或译者
- -
- name: channel
- in: query
- schema:
- type: string
- description: '来源 channel 的 uuid'
- -
- name: facets
- in: query
- schema:
- type: boolean
- default: false
- description: '是否在 `meta.facets` 里返回按 resource_type / language / category / granularity 的分面计数'
- -
- name: page
- in: query
- schema:
- type: integer
- default: 1
- description: 页码
- -
- name: per_page
- in: query
- schema:
- type: integer
- default: 20
- description: '每页条数,上限 100'
- responses:
- 200:
- description: 成功
- content:
- application/json:
- schema:
- type: object
- properties:
- data:
- type: array
- items:
- type: object
- properties:
- id:
- type: string
- resource_type:
- type: string
- resource_id:
- type: string
- nullable: true
- granularity:
- type: string
- nullable: true
- language:
- type: string
- nullable: true
- related_id:
- type: string
- nullable: true
- score:
- type: number
- nullable: true
- title:
- type: string
- content:
- type: string
- highlight:
- type: string
- nullable: true
- bold:
- type: array
- items: { type: string }
- path:
- type: string
- nullable: true
- category:
- type: array
- items: { type: string }
- tags:
- type: array
- items: { type: string }
- updated_at:
- type: string
- nullable: true
- display:
- type: string
- description: 仅在部分查询口径下返回。
- meta:
- type: object
- properties:
- current_page:
- type: integer
- description: 当前页
- per_page:
- type: integer
- description: 每页条数
- total:
- type: integer
- description: '命中总数(total_relation 为 gte 时是下限)'
- total_relation:
- type: string
- description: 'eq 精确,gte 表示「至少这么多」(OpenSearch 只精确计数到 10000)'
- last_page:
- type: integer
- description: 最后一页(受翻页深度限制)
- facets:
- type: object
- description: '分面计数,只在 facets=true 时出现。键是 resource_type / language / category / granularity'
- additionalProperties:
- type: array
- items: { type: object, required: [key, count], properties: { key: { type: string }, count: { type: integer } } }
- 422:
- $ref: '../../main.yaml#/components/responses/ProblemValidation'
- 503:
- description: 搜索服务暂不可用
- content:
- application/problem+json:
- schema:
- $ref: '../../main.yaml#/components/schemas/ProblemDetails'
- post:
- summary: 全文检索(POST)
- tags:
- - search
- operationId: post_api_v3_search
- description: |-
- 与 `GET /v3/search` 完全等价,参数放在 JSON 请求体里(数组参数多、URL 放不下时用)。
- 实现:`V3\SearchController@store`
- security:
- - { }
- -
- bearerAuth: []
- requestBody:
- required: true
- content:
- application/json:
- schema:
- type: object
- properties:
- q:
- type: string
- description: 检索词
- search_mode:
- type: string
- description: 检索模式
- enum:
- - fuzzy
- - exact
- - semantic
- - hybrid
- - definition
- default: fuzzy
- resource_type:
- type: string
- description: 资源类型
- enum:
- - tipitaka
- - original_text
- - term
- resource_id:
- type: string
- description: '限定某个资源 id'
- granularity:
- type: string
- description: 文档颗粒度
- enum:
- - book
- - chapter
- - session
- - paragraph
- language:
- type: string
- description: 文档语言
- category:
- type: string
- description: 分类,逗号分隔,须全部命中
- tags:
- type: string
- description: 标签,逗号分隔,命中任一
- page_refs:
- type: array
- description: 页码标记,命中任一
- related_id:
- type: array
- description: '关联 id,命中任一'
- author:
- type: string
- description: 作者或译者
- channel:
- type: string
- description: '来源 channel 的 uuid'
- facets:
- type: boolean
- description: 是否返回分面计数
- default: false
- page:
- type: integer
- description: 页码
- default: 1
- per_page:
- type: integer
- description: '每页条数,上限 100'
- default: 20
- required:
- - q
- responses:
- 200:
- description: 成功
- content:
- application/json:
- schema:
- type: object
- properties:
- data:
- type: array
- items:
- type: object
- properties:
- id:
- type: string
- resource_type:
- type: string
- resource_id:
- type: string
- nullable: true
- granularity:
- type: string
- nullable: true
- language:
- type: string
- nullable: true
- related_id:
- type: string
- nullable: true
- score:
- type: number
- nullable: true
- title:
- type: string
- content:
- type: string
- highlight:
- type: string
- nullable: true
- bold:
- type: array
- items: { type: string }
- path:
- type: string
- nullable: true
- category:
- type: array
- items: { type: string }
- tags:
- type: array
- items: { type: string }
- updated_at:
- type: string
- nullable: true
- display:
- type: string
- description: 仅在部分查询口径下返回。
- meta:
- type: object
- properties:
- current_page:
- type: integer
- description: 当前页
- per_page:
- type: integer
- description: 每页条数
- total:
- type: integer
- description: '命中总数(total_relation 为 gte 时是下限)'
- total_relation:
- type: string
- description: 'eq 精确,gte 表示「至少这么多」'
- last_page:
- type: integer
- description: 最后一页(受翻页深度限制)
- facets:
- type: object
- description: '分面计数,只在 facets=true 时出现。键是 resource_type / language / category / granularity'
- additionalProperties:
- type: array
- items: { type: object, required: [key, count], properties: { key: { type: string }, count: { type: integer } } }
- 422:
- $ref: '../../main.yaml#/components/responses/ProblemValidation'
- 503:
- description: 搜索服务暂不可用
- content:
- application/problem+json:
- schema:
- $ref: '../../main.yaml#/components/schemas/ProblemDetails'
|