Test name | Executions per second |
---|---|
Lunr | 115965.0 Ops/sec |
js search | 880934.0 Ops/sec |
minisearch | 71149.2 Ops/sec |
<script src="https://unpkg.com/lunr/lunr.js"></script>
<script type="text/javascript" src="https://rawgit.com/bvaughn/js-search/1.2.0/dist/js-search.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/minisearch@2.2.2/dist/umd/index.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var books = [];
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var json = JSON.parse(xmlhttp.responseText);
books = json.books;
}
}
xmlhttp.open('GET', 'http://bvaughn.github.io/js-search/books.json', true);
xmlhttp.send();
};
</script>
var idx = lunr(function () {
this.ref('isbn');
this.field('title');
this.field('author');
books.forEach(function (doc) {
this.add(doc)
}, this);
})
var search = new JsSearch.Search('isbn');
search.searchIndex = new JsSearch.TfIdfSearchIndex('isbn');
search.addIndex('title');
search.addIndex('author');
search.addDocuments(books);
var miniSearch = new MiniSearch({
fields: ['isbn', 'title', 'author'], // fields to index for full-text search
});
miniSearch.addAll(books)