mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-14 10:35:55 +08:00
feat: support explicit q passing in search
This commit is contained in:
parent
607407f740
commit
e324c4667f
@ -86,11 +86,12 @@ export class SearcherHost extends RPCHost {
|
|||||||
count: number,
|
count: number,
|
||||||
crawlerOptions: CrawlerOptions,
|
crawlerOptions: CrawlerOptions,
|
||||||
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
||||||
|
@Param('q') q?: string,
|
||||||
) {
|
) {
|
||||||
const uid = await auth.solveUID();
|
const uid = await auth.solveUID();
|
||||||
let chargeAmount = 0;
|
let chargeAmount = 0;
|
||||||
const noSlashPath = ctx.req.url.slice(1);
|
const noSlashPath = ctx.req.url.slice(1);
|
||||||
if (!noSlashPath) {
|
if (!noSlashPath && !q) {
|
||||||
const latestUser = uid ? await auth.assertUser() : undefined;
|
const latestUser = uid ? await auth.assertUser() : undefined;
|
||||||
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ export class SearcherHost extends RPCHost {
|
|||||||
delete crawlerOptions.html;
|
delete crawlerOptions.html;
|
||||||
|
|
||||||
const crawlOpts = this.crawler.configure(crawlerOptions);
|
const crawlOpts = this.crawler.configure(crawlerOptions);
|
||||||
const searchQuery = braveSearchExplicitOperators.addTo(ctx.req.path.slice(1));
|
const searchQuery = braveSearchExplicitOperators.addTo(q || ctx.req.path.slice(1));
|
||||||
const r = await this.cachedWebSearch({
|
const r = await this.cachedWebSearch({
|
||||||
q: searchQuery,
|
q: searchQuery,
|
||||||
count: Math.floor(count + 2)
|
count: Math.floor(count + 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user