Skip to content

yuxuan-ji/lunastra

Repository files navigation

Codacy Badge Known Vulnerabilities MIT Licence Size

Lunastra is a full-text search engine with focus on customization.

Installation & Usage

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
        }
    }
]

More examples

For even more examples and usage, please refer to the Wiki.

Development setup

Install Dependencies:

npm install

Build lib:

npm run build

Build non-minified and run playground:

npm run dev

Run tests:

npm run test

Acknowledgement

Lunastra is inspired by Lunr, Elasticlunr, and Coveo.

Contributing

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.

  1. Fork this repo
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Documentation

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.

About

Full-text search engine for the browser.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •