Skip to content

Commit

Permalink
fix: about search charity error
Browse files Browse the repository at this point in the history
  • Loading branch information
wwei-github committed Oct 17, 2023
1 parent ea565fa commit 08e9df2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class AppService {

async search(content: string) {
const result = {};

// eip match
if (this.isNumeric(content)) {
const eipRecords = await this.connection.query(
Expand All @@ -93,15 +92,16 @@ export class AppService {
} else {
// title match
const titleRecords = await this.connection.query(
`SELECT eip, type, category, ts_headline(title, q), rank FROM (SELECT eip, type, category, title, q, ts_rank_cd(title_ts, q) AS rank FROM "EIPs", phraseto_tsquery('${content}') q WHERE title_ts @@ q ORDER BY rank DESC LIMIT 20) AS foo;`,
`SELECT eip, type, category, ts_headline(title, q), rank FROM (SELECT eip, type, category, title, q, ts_rank_cd(title_ts, q) AS rank FROM "EIPs", phraseto_tsquery('english','${content}') q WHERE title_ts @@ q ORDER BY rank DESC LIMIT 20) AS foo;`,
);

if (titleRecords && titleRecords.length > 0) {
result['title_list'] = titleRecords;
}

// content match
const contentRecords = await this.connection.query(
`SELECT eip, type, category, title, ts_headline(content, q), rank FROM (SELECT eip, type, category, title, content, q, ts_rank_cd(content_ts, q) AS rank FROM "EIPs", phraseto_tsquery('${content}') q WHERE content_ts @@ q ORDER BY rank DESC LIMIT 20) AS foo;`,
`SELECT eip, type, category, title, ts_headline(content, q), rank FROM (SELECT eip, type, category, title, content, q, ts_rank_cd(content_ts, q) AS rank FROM "EIPs", phraseto_tsquery('english','${content}') q WHERE content_ts @@ q ORDER BY rank DESC LIMIT 20) AS foo;`,
);
if (contentRecords && contentRecords.length > 0) {
result['content_list'] = contentRecords;
Expand Down

0 comments on commit 08e9df2

Please sign in to comment.