chore: expose 'num' param for search API (#1157)

* chore: expose 'num' param for search API

* fix: wrong count value
This commit is contained in:
Aaron Ji 2025-03-05 11:20:55 +08:00 committed by GitHub
parent a7ffb58741
commit ed80c9a4a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,14 +85,21 @@ export class SearcherHost extends RPCHost {
auth: JinaEmbeddingsAuthDTO,
crawlerOptions: CrawlerOptions,
searchExplicitOperators: GoogleSearchExplicitOperatorsDto,
@Param('count', { default: 5, validate: (v) => v >= 0 && v <= 20 })
@Param('count', { validate: (v: number) => v >= 0 && v <= 20 })
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('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
@Param('location') location?: string,
@Param('page') page?: number,
@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();
// Return content by default
const respondWith = ctx.req.get('X-Respond-With') ?? 'content';