Skip to content

Commit

Permalink
feat: add more fields to collated search documents
Browse files Browse the repository at this point in the history
  • Loading branch information
drodil committed Sep 5, 2024
1 parent a57d012 commit 57c35ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/qeta-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ export interface QetaDocument extends IndexableDocument {
docType: string;
author: string;
score: number;
entityRefs?: string[];
answerCount?: number;
views?: number;
tags?: string[];
correctAnswer?: boolean;
}

interface CustomError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,25 @@ export class DefaultQetaCollatorFactory implements DocumentCollatorFactory {
docType: 'qeta',
author: question.author,
score: question.score,
entityRefs: question.entities,
answerCount: question.answersCount,
views: question.views,
tags: question.tags,
};

for (const answer of question.answers ?? []) {
yield {
title: `Answer for ${question.title}`,
title: `${
answer.correct ? 'Correct answer' : 'Answer'
} for question ${question.title}`,
text: answer.content,
location: `/qeta/questions/${question.id}#answer_${answer.id}`,
docType: 'qeta',
entityRefs: question.entities,
author: answer.author,
score: answer.score,
tags: question.tags,
correctAnswer: answer.correct,
};

for (const comment of answer.comments ?? []) {
Expand All @@ -116,6 +121,7 @@ export class DefaultQetaCollatorFactory implements DocumentCollatorFactory {
author: comment.author,
score: answer.score,
tags: question.tags,
entityRefs: question.entities,
};
}
}
Expand All @@ -129,6 +135,7 @@ export class DefaultQetaCollatorFactory implements DocumentCollatorFactory {
author: comment.author,
score: question.score,
tags: question.tags,
entityRefs: question.entities,
};
}
}
Expand Down

0 comments on commit 57c35ea

Please sign in to comment.