Skip to content

Commit 20dce66

Browse files
authored
Fix/search v5 (#209)
* fix(search): store mentions in elasticsearch * fix(search): search query in mentions
1 parent 6b98d62 commit 20dce66

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/background-jobs/elasticsearch/es-sync.processor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ export class EsSyncProcessor {
298298
following: tweet.user?.following || 0,
299299
images: tweet.images || [],
300300
videos: tweet.videos || [],
301+
mentions: tweet.mentions || [],
301302
bio: tweet.user?.bio,
302303
avatar_url: tweet.user?.avatar_url,
303304
};

src/elasticsearch/schemas/tweets.schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export const tweets_index_config = {
6363
hashtags: {
6464
type: 'keyword',
6565
},
66+
mentions: {
67+
type: 'keyword',
68+
},
6669
created_at: {
6770
type: 'date',
6871
},

src/elasticsearch/seeders/tweets-seeder.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export class TweetSeederService {
122122
following: tweet.user?.following || 0,
123123
images: tweet.images || [],
124124
videos: tweet.videos || [],
125+
mentions: tweet.mentions || [],
125126
bio: tweet.user?.bio,
126127
avatar_url: tweet.user?.avatar_url,
127128
};

src/search/search.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ export class SearchService {
402402
},
403403
images: parent_source.images ?? [],
404404
videos: parent_source.videos ?? [],
405+
mentions: parent_source.mentions ?? [],
405406
};
406407
}
407408

@@ -426,6 +427,7 @@ export class SearchService {
426427
},
427428
images: conversation_source.images ?? [],
428429
videos: conversation_source.videos ?? [],
430+
mentions: parent_source.mentions ?? [],
429431
};
430432
}
431433

@@ -451,7 +453,14 @@ export class SearchService {
451453
{
452454
multi_match: {
453455
query: sanitized_query.trim(),
454-
fields: ['content^3', 'content.arabic^3', 'username^2', 'name', 'name.arabic'],
456+
fields: [
457+
'content^3',
458+
'content.arabic^3',
459+
'username^2',
460+
'name',
461+
'name.arabic',
462+
'mentions^2',
463+
],
455464
type: 'best_fields',
456465
fuzziness: 'AUTO',
457466
prefix_length: 1,

0 commit comments

Comments
 (0)