{"id":16015001,"url":"https://github.com/louismazel/maz-smart-search","last_synced_at":"2026-02-06T21:32:23.954Z","repository":{"id":36828018,"uuid":"229262534","full_name":"LouisMazel/maz-smart-search","owner":"LouisMazel","description":"Smart-Search is a JavaScript library that perform fuzzy-search through a list of entries.","archived":false,"fork":false,"pushed_at":"2023-01-06T02:21:55.000Z","size":334,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-31T13:13:14.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LouisMazel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-20T12:39:26.000Z","updated_at":"2020-06-17T09:01:39.000Z","dependencies_parsed_at":"2023-01-17T05:21:57.579Z","dependency_job_id":null,"html_url":"https://github.com/LouisMazel/maz-smart-search","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisMazel%2Fmaz-smart-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisMazel%2Fmaz-smart-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisMazel%2Fmaz-smart-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisMazel%2Fmaz-smart-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LouisMazel","download_url":"https://codeload.github.com/LouisMazel/maz-smart-search/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisMazel%2Fmaz-smart-search/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259106728,"owners_count":22805941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T15:05:49.607Z","updated_at":"2026-02-06T21:32:23.927Z","avatar_url":"https://github.com/LouisMazel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smart-Search\n\n![logo](./assets/logo.png)\n\n\u003e Smart-Search is a JavaScript library that perform fuzzy-search through a list of entries.\n\n## Install\n\n### Yarn\n\n```bash\nyarn add maz-smart-search\n```\n\n### Npm\n\n```bash\nnpm install maz-smart-search --save\n```\n\n### CDN\n\n```javascript\n\u003cscript src=\"https://unpkg.com/vue-mazel-ui/dist/smart-search.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```javascript\nvar results = smartSearch(entries, patterns, fields, options);\n```\n\n### Parameters\n\n- **entries** `Array\u003cObject\u003e`\n\n    List of objects where the search will perform. ([see details](#entries))\n\n- **patterns** `Array\u003cString\u003e`\n\n    List of patterns that will be searched in the **_entries_**. ([see details](#patterns))\n\n- **fields** `Array\u003cString\u003e`\n\n    List of **_entries_**'s properties where all the **_patterns_** will be searched. ([see details](#fields))\n\n- **options** `Object`\n\n    Optional properties. ([see details](#options))\n\n### Return `Array\u003cObject\u003e`\n\nThe return is an array of objects containing the **_entries_** that have matched. ([see details](#Return))\n\n## Example\n\n```javascript\nvar entries = [\n  { id:0, name:'Robin David',     email:'robin.david@gmail.com' },\n  { id:1, name:'Loris Francois',  email:'loris.francois@gmail.com' },\n  { id:2, name:'Armand Roy',      email:'armand.roy@live.com' },\n  { id:3, name:'Mathias Meunier', email:'mathias.meunier@gmail.com' },\n  { id:4, name:'Ruben Bernard',   email:'ruben.bernard@yahoo.com' },\n];\n\nvar patterns = ['gmail', 'oi'];\nvar fields = { name: true, email: true };\n\nvar results = smartSearch(entries, patterns, fields);\n\nresults.forEach( function (result) {\n  console.log(result.entry);\n});\n```\n\nwill display :\n\n\u003cpre\u003e\n  { id: 1, name: 'Loris Franc\u003cb\u003eoi\u003c/b\u003es', email: 'loris.franc\u003cb\u003eoi\u003c/b\u003es@\u003cb\u003egmail\u003c/b\u003e.com' }\n  { id: 0, name: 'R\u003cb\u003eo\u003c/b\u003eb\u003cb\u003ei\u003c/b\u003en David', email: 'r\u003cb\u003eo\u003c/b\u003eb\u003cb\u003ei\u003c/b\u003en.david@\u003cb\u003egmail\u003c/b\u003e.com' }\n\u003c/pre\u003e\n\n## Details\n\n### Parameters\n\n#### entries `Array\u003cObject\u003e`\n\nList of objects where the search is performed.\n\n\u003e Example:\n\n```javascript\nvar entries = [\n  { id:0, name:'Robin David',     email:'robin.david@gmail.com' },\n  { id:1, name:'Loris Francois',  email:'loris.francois@gmail.com' },\n  { id:2, name:'Armand Roy',      email:'armand.roy@live.com' },\n  { id:3, name:'Mathias Meunier', email:'mathias.meunier@gmail.com' },\n  { id:4, name:'Ruben Bernard',   email:'ruben.bernard@yahoo.com' },\n];\n```\n\n#### patterns `Array\u003cString\u003e`\n\nList of patterns that are searched in the **_entries_**.\n\nEach pattern is searched accross the specified properties (**_fields_**) of every entry.\n\nA pattern match a string if all the letters that it is constituted appears, in the same order, in the string.\nThe relevance of the matching is computed from the minimum number of letters that have be inserted into the pattern in such a way it matches the string.\n\n\u003e Example:\n\n\u003cpre\u003e\n  the pattern 'oi'\n    - match with 0 insertions in 'Loris Franc\u003cb\u003eoi\u003c/b\u003es'\n    - match with 1 insertions in 'R\u003cb\u003eo\u003c/b\u003eb\u003cb\u003ei\u003c/b\u003en David'\n\u003c/pre\u003e\n\n*The optional parameter 'maxInsertions' limit the number of insertions authorised.*\n\n#### fields `Array\u003cString\u003e`\n\nList of objects's properties where the **_patterns_** are searched.\n\nThe property's value should be a `String`. If not, the property is ignored.\n\nNested properties could be specified with a dot character.\n\n\u003e Example:\n\n```javascript\nvar entries = [\n  {\n    id:0,\n    name:{ first:{ 'Robin' }, last:{ 'David' } },\n    email:'robin.david@gmail.com'\n  },\n  {...}\n];\nvar results = smartSearch(entries, patterns, { name: { last: true }, email: true });\n```\n\n#### options `Object`\n\nAn optional fourth parameter allow user to customize search behavior.\n\nThe options available are :\n\n- **caseSensitive** `Boolean` *(default:false)*\n\n    Indicates whether matching should be case sensitive.\n\n- **fieldMatching** `Boolean` *(default:false)*\n\n    By default an entry match if all patterns match through the **entire entry**.\n\n    With `fieldMatching = true`, an entry match if all patterns match in at least **one field**.\n\n- **maxInsertions** `Integer` *(default:-1)*\n\nIndicate the maximum of insertions authorisedduring pattern matching.\n\n`maxInsertions = -1` means no limit.\n\n\u003e Example:\n\n```javascript\nvar options = {\n  maxInsertions: 3;\n};\nvar results = smartSearch(entries, patterns, fields, options);\n```\n\n#### Return `Array\u003cObject\u003e`\n\nThe return value is an array of objects containing the entries that have matched all the patterns.\n\nThe properties of each returned object are the following:\n\n- **entry** : original entry from the **_entries_** array.\n- **info** : informations about the matching.\n- **score** : relevance score.\n\n\u003e Example:\n\n```javascript\n[\n  {\n    entry:{id:1, name:'Loris Francois', email:'loris.francois@gmail.com'},\n    info:[\n    {\n      field:'name',\n      patterns:[\n      {value:'oi', insertions:0, matchIndexes:[11,12]},\n      ]\n    },\n    {\n      field:'email',\n      patterns:[\n      {value:'gmail', insertions:0, matchIndexes:[15,16,17,18,19]},\n      {value:'oi', insertions:0, matchIndexes:[11,12]},\n      ]\n    },\n    ],\n    score:0.011\n  },\n  {\n    entry:{id:0, name:'Robin David', email:'robin.david@gmail.com'},\n    info:[\n    {\n      field:'name',\n      patterns:[\n      {value:'oi', insertions:1, matchIndexes:[1,3]},\n      ]\n    },\n    {\n      field:'email',\n      patterns:[\n      {value:'gmail', insertions:0, matchIndexes:[12,13,14,15,16]},\n      {value:'oi', insertions:1, matchIndexes:[1,3]},\n      ]\n    },\n    ],\n    score:1.001\n  }\n]\n```\n\n---\n\n## License\n\n[MIT](./LICENCE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouismazel%2Fmaz-smart-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouismazel%2Fmaz-smart-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouismazel%2Fmaz-smart-search/lists"}