Merge upstream
This commit is contained in:
commit
a8828c6485
@ -174,6 +174,7 @@ export class SearchService {
|
||||
if (note.text == null && note.cw == null) return;
|
||||
// if (!['home', 'public'].includes(note.visibility)) return;
|
||||
|
||||
const createdAt = this.idService.parse(note.id).date;
|
||||
if (this.meilisearch) {
|
||||
switch (this.meilisearchIndexScope) {
|
||||
case 'global':
|
||||
@ -192,7 +193,7 @@ export class SearchService {
|
||||
|
||||
await this.meilisearchNoteIndex?.addDocuments([{
|
||||
id: note.id,
|
||||
createdAt: this.idService.parse(note.id).date.getTime(),
|
||||
createdAt: createdAt.getTime(),
|
||||
userId: note.userId,
|
||||
userHost: note.userHost,
|
||||
channelId: note.channelId,
|
||||
@ -204,7 +205,7 @@ export class SearchService {
|
||||
});
|
||||
} else if (this.elasticsearch) {
|
||||
const body = {
|
||||
createdAt: this.idService.parse(note.id).date.getTime(),
|
||||
createdAt: createdAt.getTime(),
|
||||
userId: note.userId,
|
||||
userHost: note.userHost,
|
||||
channelId: note.channelId,
|
||||
@ -213,11 +214,11 @@ export class SearchService {
|
||||
tags: note.tags,
|
||||
};
|
||||
await this.elasticsearch.index({
|
||||
index: this.elasticsearchNoteIndex + `-${new Date().toISOString().slice(0, 7).replace(/-/g, '')}` as string,
|
||||
index: `${this.elasticsearchNoteIndex}-${createdAt.toISOString().slice(0, 7).replace(/-/g, '')}`,
|
||||
id: note.id,
|
||||
body: body,
|
||||
}).catch((error: any) => {
|
||||
console.error(error);
|
||||
this.logger.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -228,6 +229,13 @@ export class SearchService {
|
||||
|
||||
if (this.meilisearch) {
|
||||
this.meilisearchNoteIndex?.deleteDocument(note.id);
|
||||
} else if (this.elasticsearch) {
|
||||
await this.elasticsearch.delete({
|
||||
index: `${this.elasticsearchNoteIndex}-${this.idService.parse(note.id).date.toISOString().slice(0, 7).replace(/-/g, '')}`,
|
||||
id: note.id,
|
||||
}).catch((error) => {
|
||||
this.logger.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user