mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-07-31 01:06:59 +08:00
chore: expose 'num' param for search API (#1157)
* chore: expose 'num' param for search API * fix: wrong count value
This commit is contained in:
parent
a7ffb58741
commit
ed80c9a4a2
@ -85,14 +85,21 @@ export class SearcherHost extends RPCHost {
|
|||||||
auth: JinaEmbeddingsAuthDTO,
|
auth: JinaEmbeddingsAuthDTO,
|
||||||
crawlerOptions: CrawlerOptions,
|
crawlerOptions: CrawlerOptions,
|
||||||
searchExplicitOperators: GoogleSearchExplicitOperatorsDto,
|
searchExplicitOperators: GoogleSearchExplicitOperatorsDto,
|
||||||
@Param('count', { default: 5, validate: (v) => v >= 0 && v <= 20 })
|
@Param('count', { validate: (v: number) => v >= 0 && v <= 20 })
|
||||||
count: number,
|
count: number,
|
||||||
|
@Param('num', { validate: (v: number) => v >= 0 && v <= 20 })
|
||||||
|
num?: number,
|
||||||
@Param('gl', { validate: (v: string) => WORLD_COUNTRY_CODES.includes(v) }) gl?: string,
|
@Param('gl', { validate: (v: string) => WORLD_COUNTRY_CODES.includes(v) }) gl?: string,
|
||||||
@Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
|
@Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
|
||||||
@Param('location') location?: string,
|
@Param('location') location?: string,
|
||||||
@Param('page') page?: number,
|
@Param('page') page?: number,
|
||||||
@Param('q') q?: string,
|
@Param('q') q?: string,
|
||||||
) {
|
) {
|
||||||
|
// We want to make our search API follow SERP schema, so we need to expose 'num' parameter.
|
||||||
|
// Since we used 'count' as 'num' previously, we need to keep 'count' for old users.
|
||||||
|
// Here we combine 'count' and 'num' to 'count' for the rest of the function.
|
||||||
|
count = (num !== undefined ? num : count) ?? 5;
|
||||||
|
|
||||||
const uid = await auth.solveUID();
|
const uid = await auth.solveUID();
|
||||||
// Return content by default
|
// Return content by default
|
||||||
const respondWith = ctx.req.get('X-Respond-With') ?? 'content';
|
const respondWith = ctx.req.get('X-Respond-With') ?? 'content';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user