diff --git a/jest.config.js b/jest.config.js index 319b922..d723bfa 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,5 @@ module.exports = { preset: "ts-jest", testEnvironment: "node", + testPathIgnorePatterns: ["!*.d.ts"], }; diff --git a/package.json b/package.json index 463587c..0a6bbf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monolieta-search", - "version": "1.1.0", + "version": "1.1.1", "description": "Search library for browser and Node.js", "main": "dist/index.js", "module": "dist/index.esm.js", diff --git a/src/__tests__/search.test.ts b/src/__tests__/search.test.ts index 7639222..c90e422 100644 --- a/src/__tests__/search.test.ts +++ b/src/__tests__/search.test.ts @@ -132,7 +132,7 @@ describe("Search", () => { expect(search.search("hobbit")).toEqual(["002"]); }); - it("demo", () => { + it("demo 1", () => { const client = new Search({ exactWordStrategy: false, unorderedDocument: false, @@ -144,4 +144,23 @@ describe("Search", () => { expect(client.search("Ring")).toEqual(["001"]); }); + + it("demo 2", () => { + const client = new Search({ + caseSensitive: false, + exactWordStrategy: false, + ignoreAccent: true, + stopWord: { + de: true, + }, + unorderedDocument: false, + }); + + client.index("003", "Piezas"); + client.index("007", "Préstamo de Herramientas"); + client.index("008", "Evaluación de proveedores"); + + expect(client.search("proveedores")).toEqual(["008"]); + expect(client.search("pr")).toEqual(["007", "008"]); + }); }); diff --git a/src/search.ts b/src/search.ts index bc9725f..c3fcfd9 100644 --- a/src/search.ts +++ b/src/search.ts @@ -53,10 +53,8 @@ export class Search { this.document.insert(uid, this.strategy.apply(this.prepare(body))); } - search(text: string): string[] { - return this.document.search( - this.strategy.apply(this.tokenizer.tokenize(text)) - ); + search(query: string): string[] { + return this.document.search(this.tokenizer.tokenize(query)); } isEmpty() {