diff --git a/packages/full-text-search-language/spec/helper/create_lanuage_test.ts b/packages/full-text-search-language/spec/helper/create_lanuage_test.ts index 13affcd2..ecf02f40 100644 --- a/packages/full-text-search-language/spec/helper/create_lanuage_test.ts +++ b/packages/full-text-search-language/spec/helper/create_lanuage_test.ts @@ -31,7 +31,7 @@ export function createLanguageTest(language: string, data: LanguageTestData) { let fts = new FullTextSearch([{ name: "body", tokenizer: data.tokenizer - }]); + }], "$loki"); // Add documents. for (let i = 0; i < data.docs.length; i++) { diff --git a/packages/full-text-search/spec/generic/search/fuzzy.spec.ts b/packages/full-text-search/spec/generic/search/fuzzy.spec.ts index f79fe150..72e4faa4 100644 --- a/packages/full-text-search/spec/generic/search/fuzzy.spec.ts +++ b/packages/full-text-search/spec/generic/search/fuzzy.spec.ts @@ -37,7 +37,7 @@ describe("fuzzy query", () => { it("Fuzzy query (1).", () => { let docs = ["aaaaa", "aaaab", "aaabb", "aabbb", "abbbb", "bbbbb", "ddddd"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -141,7 +141,7 @@ describe("fuzzy query", () => { it("Fuzzy query (2).", () => { let docs = ["lange", "lueth", "pirsing", "riegel", "trzecziak", "walker", "wbr", "we", "web", "webe", "weber", "webere", "webree", "weberei", "wbre", "wittkopf", "wojnarowski", "wricke"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -164,7 +164,7 @@ describe("fuzzy query", () => { return tokens.split(" "); }); - let fts = new FullTextSearch([{name: "body", tokenizer: tkz}]); + let fts = new FullTextSearch([{name: "body", tokenizer: tkz}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -178,7 +178,7 @@ describe("fuzzy query", () => { it("Fuzzy query extended.", () => { let docs = ["walker", "wbr", "we", "web", "webe", "weber", "webere", "webree", "weberei", "wbes", "wbert", "wbb", "xeb", "wrr", "wrr"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -195,7 +195,7 @@ describe("fuzzy query", () => { it("Fuzzy query extended.", () => { let docs = ["abca", "abcd", "abcde"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, diff --git a/packages/full-text-search/spec/generic/search/wildcard.spec.ts b/packages/full-text-search/spec/generic/search/wildcard.spec.ts index 27d2293f..a2a2c16f 100644 --- a/packages/full-text-search/spec/generic/search/wildcard.spec.ts +++ b/packages/full-text-search/spec/generic/search/wildcard.spec.ts @@ -22,7 +22,7 @@ describe("wildcard query", () => { it("Tests Wildcard queries with an asterisk.", () => { let docs = ["metal", "metals", "mXtals", "mXtXls"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -56,7 +56,7 @@ describe("wildcard query", () => { it("Tests Wildcard queries with a question mark.", () => { let docs = ["metal", "metals", "mXtals", "mXtXls"]; - let fts = new FullTextSearch([{name: "body"}]); + let fts = new FullTextSearch([{name: "body"}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, @@ -85,7 +85,7 @@ describe("wildcard query", () => { // Don't split the text. tkz.setSplitter("nosplit", (text) => [text]); - let fts = new FullTextSearch([{name: "body", tokenizer: tkz}]); + let fts = new FullTextSearch([{name: "body", tokenizer: tkz}], "$loki"); for (let i = 0; i < docs.length; i++) { fts.addDocument({ $loki: i, diff --git a/packages/full-text-search/spec/node/elasticsearch.spec.ts b/packages/full-text-search/spec/node/elasticsearch.spec.ts index c2c04600..ca9c9df2 100644 --- a/packages/full-text-search/spec/node/elasticsearch.spec.ts +++ b/packages/full-text-search/spec/node/elasticsearch.spec.ts @@ -269,7 +269,7 @@ describe("Compare scoring against elasticsearch", () => { let fts = new FullTextSearch([{ name: FIELD_NAME_1, tokenizer: tkz - }]); + }], "$loki"); // Add documents. for (let i = 0; i < DATA.length; i++) { diff --git a/packages/full-text-search/src/full_text_search.ts b/packages/full-text-search/src/full_text_search.ts index c8755c9a..716ba28f 100644 --- a/packages/full-text-search/src/full_text_search.ts +++ b/packages/full-text-search/src/full_text_search.ts @@ -28,9 +28,9 @@ export class FullTextSearch { * @param {boolean=true} fields.optimizeChanges - flag to indicate if deleting/updating a document should be optimized * (requires more memory but performs better) * @param {Tokenizer=Tokenizer} fields.tokenizer - the tokenizer of the field - * @param {string=$loki} id - the property name of the document index + * @param {string} [id] - the property name of the document index */ - constructor(fields: FullTextSearch.FieldOptions[] = [], id = "$loki") { + constructor(fields: FullTextSearch.FieldOptions[] = [], id?: string) { // Create inverted indices for each field. for (let i = 0; i < fields.length; i++) { let field = fields[i];