Lunastra is a full-text search engine with focus on customization.
ES6:
import * as Lunastra from './Lunastra.min.js';
From script:
<script src="https://cdn.jsdelivr.net/gh/yuxuan-ji/lunastra@master/dist/Lunastra.min.js"></script>
From there, a simple Index be created like so:
var doc1 = {title: 'Foo', body: 'Bar', author: '[email protected]', date:'foo/bar/baz'};
var index = Lunastra.init({
generateIds: true,
id: 'id',
fields: ['title', 'body', 'author', 'date'],
documents: [doc1]
});
Searching can be done on the indexed fields of the documents:
index.search('Bar')
>> // Returns an array of search results
[
{
"id": "1",
"score": 0.3068528194400547,
"doc": {
"title": "Foo",
"body": "Bar",
"author": "[email protected]",
"date": "foo/bar/baz",
"id": 1
}
}
]
For even more examples and usage, please refer to the Wiki.
Install Dependencies:
npm install
Build lib:
npm run build
Build non-minified and run playground:
npm run dev
Run tests:
npm run test
Lunastra is inspired by Lunr, Elasticlunr, and Coveo.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
- Fork this repo
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Documentation is generated with JsDoc and jsdoc2md and located in their respective locations in src/. Run:
npm run build:docs
to generate the documentation automatically from your JsDoc comments.