Improves ordering of search results

Modifies documents.search to return a context snippet and search ranking
Displays context snipped on search results screen
This commit is contained in:
Tom Moor
2018-08-04 18:32:56 -07:00
parent 96348ced38
commit e192bcbaee
10 changed files with 121 additions and 63 deletions

View File

@ -64,14 +64,14 @@ router.post('hooks.slack', async ctx => {
if (!user) throw new InvalidRequestError('Invalid user');
const documents = await Document.searchForUser(user, text, {
const results = await Document.searchForUser(user, text, {
limit: 5,
});
if (documents.length) {
if (results.length) {
const attachments = [];
for (const document of documents) {
attachments.push(presentSlackAttachment(document));
for (const result of results) {
attachments.push(presentSlackAttachment(result.document));
}
ctx.body = {