{"id":15022905,"url":"https://github.com/charizard/ember-cli-lunr","last_synced_at":"2025-08-22T00:39:45.333Z","repository":{"id":57223353,"uuid":"60030475","full_name":"Charizard/ember-cli-lunr","owner":"Charizard","description":"Simple full-text search for ember-cli apps using lunr.js","archived":false,"fork":false,"pushed_at":"2019-04-01T23:43:32.000Z","size":199,"stargazers_count":10,"open_issues_count":4,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-22T13:02:07.066Z","etag":null,"topics":["ember-addon","ember-cli-addon","emberjs","lunr","search","search-in-text"],"latest_commit_sha":null,"homepage":"http://lunrjs.com/","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/Charizard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-30T18:21:41.000Z","updated_at":"2020-09-09T03:34:08.000Z","dependencies_parsed_at":"2022-08-24T15:41:47.656Z","dependency_job_id":null,"html_url":"https://github.com/Charizard/ember-cli-lunr","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Charizard%2Fember-cli-lunr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Charizard%2Fember-cli-lunr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Charizard%2Fember-cli-lunr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Charizard%2Fember-cli-lunr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Charizard","download_url":"https://codeload.github.com/Charizard/ember-cli-lunr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867595,"owners_count":16554396,"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":["ember-addon","ember-cli-addon","emberjs","lunr","search","search-in-text"],"created_at":"2024-09-24T19:58:30.820Z","updated_at":"2024-09-24T21:27:09.204Z","avatar_url":"https://github.com/Charizard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-cli-lunr\n[![npm version](https://badge.fury.io/js/ember-cli-lunr.svg)](https://badge.fury.io/js/ember-cli-lunr) [![Code Climate](https://codeclimate.com/github/Charizard/ember-cli-lunr/badges/gpa.svg)](https://codeclimate.com/github/Charizard/ember-cli-lunr) [![Build Status](https://travis-ci.org/Charizard/ember-cli-lunr.svg)](https://travis-ci.org/Charizard/ember-cli-lunr)\n\nSimple full-text search for ember-cli apps using [lunr.js](http://lunrjs.com/).\n\n## Description\n\nThis is a ember-cli wrapper for [lunr.js]( https://github.com/olivernn/lunr.js ), a small full-text search library for use in the browser. It indexes JSON documents and provides a simple search interface for retrieving documents that best match text queries.\n\n## Installation\n\nInstalling the library is as easy as:\n\n```bash\nember install ember-cli-lunr\n```\n\n## Configuring\n\nLunr 2.0 uses immutable index, so, you'll have to have an array of items to be searched beforehand. For usage with Lunr 1.0, see [0.0.5](https://github.com/Charizard/ember-cli-lunr/tree/v0.0.5) of this add-on.\n\nGiven a model named post,\n\n```js\n// app/pods/post/model.js\nimport DS from 'ember-data';\n\nexport default DS.Model.extend({\n  title: DS.attr('string'),\n  body: DS.attr('string'),\n});\n```\nFirst, you'll have to create an index with the documents (keep in mind indexes are immutable) using the Lunr class,\n\n```js\nimport Lunr from 'ember-cli-lunr/lunr';\n...\n// Pass in models to create method, this indexes all properties on the model.\nlet posts = Lunr.create({ models: get(this, 'posts') });\n\n// Or you could specify just the properties that you want to index via the properties key.\nlet posts = Lunr.create({ models: get(this, 'posts'), properties: ['title'] });\n```\n\nNow, you can search anywhere in your app using the `search` method. This method is just a wrapper around lunr.js [search](https://lunrjs.com/docs/lunr.Index.html) method. For more advanced searching, checkout the lunr.js [guides](https://lunrjs.com/guides/searching.html#scoring).\n\n```js\nposts.search('lorem ipsum');\n```\n\nPutting this all together in a controller,\n\n```js\n// app/pods/posts/controller.js\nimport Controller from '@ember/controller';\nimport { get, set } from '@ember/object';\nimport Lunr from 'ember-cli-lunr/lunr';\n\nexport default Controller.extend({\n  // assuming posts array was set on controller from\n  // setupController in route.\n  posts: null,\n  searchQuery: null,\n\n  init() {\n    this._super(...arguments);\n    let postsIndex = Lunr.create({ models: get(this, 'posts') });\n    set(this, 'postsIndex', postsIndex);\n  },\n\n  result: computed('searchQuery', function() {\n    var query = this.get('searchQuery'),\n        resultIds = get(this, 'postsIndex').search(query).mapBy('ref');\n\n    return items.filter(function(item) {\n      return resultIds.contains(item.get('id'));\n    });\n  });\n});\n```\n\n## Support\n\nPlease leave a :star: to show some support. Thanks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharizard%2Fember-cli-lunr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharizard%2Fember-cli-lunr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharizard%2Fember-cli-lunr/lists"}