Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
Update lunr type (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgto committed Apr 14, 2020
1 parent e9db844 commit 8438caf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/inquirer": "^0.0.43",
"@types/jasmine": "^3.3.12",
"@types/lowdb": "^1.0.5",
"@types/lunr": "^2.1.6",
"@types/lunr": "^2.3.3",
"@types/node": "^10.9.4",
"@types/node-fetch": "^2.1.2",
"@types/node-forge": "^0.7.5",
Expand Down
20 changes: 10 additions & 10 deletions src/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export class SearchService implements SearchServiceAbstraction {
this.index = null;
const builder = new lunr.Builder();
builder.ref('id');
(builder as any).field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) });
(builder as any).field('name', { boost: 10 });
(builder as any).field('subtitle', {
builder.field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) });
builder.field('name', { boost: 10 });
builder.field('subtitle', {
boost: 5,
extractor: (c: CipherView) => {
if (c.subTitle != null && c.type === CipherType.Card) {
Expand All @@ -53,16 +53,16 @@ export class SearchService implements SearchServiceAbstraction {
},
});
builder.field('notes');
(builder as any).field('login.username', {
builder.field('login.username', {
extractor: (c: CipherView) => c.type === CipherType.Login && c.login != null ? c.login.username : null,
});
(builder as any).field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
(builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
(builder as any).field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) });
(builder as any).field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) });
(builder as any).field('attachments_joined',
builder.field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
builder.field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
builder.field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) });
builder.field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) });
builder.field('attachments_joined',
{ extractor: (c: CipherView) => this.attachmentExtractor(c, true) });
(builder as any).field('organizationid', { extractor: (c: CipherView) => c.organizationId });
builder.field('organizationid', { extractor: (c: CipherView) => c.organizationId });
const ciphers = await this.cipherService.getAllDecrypted();
ciphers.forEach((c) => builder.add(c));
this.index = builder.build();
Expand Down

0 comments on commit 8438caf

Please sign in to comment.