JS Search vs Lunr JS - Building Index (v5)

Revision 5 of this benchmark created by Brian Vaughn on


Preparation HTML

<script type="text/javascript" src="https://rawgit.com/olivernn/lunr.js/master/lunr.js"></script>
<script type="text/javascript" src="https://rawgit.com/bvaughn/js-search/1.2.0/dist/js-search.js"></script>

Setup

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();

Test runner

Ready to run.

Testing in
TestOps/sec
Lunr JS: Building index
var lunrJsIndex = new lunr.Index

lunrJsIndex.field('title')
lunrJsIndex.field('author')
lunrJsIndex.ref('isbn')

for (var i = 0, length = books.length; i < length; i++) {
  lunrJsIndex.add(books[i]);
}
ready
JS Search: Building index (TF-IDF enabled)
var search = new JsSearch.Search('isbn');
search.searchIndex = new JsSearch.TfIdfSearchIndex('isbn');
search.addIndex('title');
search.addIndex('author');
search.addDocuments(books);
ready
JS Search: Building index (TF-IDF disabled)
var search = new JsSearch.Search('isbn');
search.searchIndex = new JsSearch.UnorderedSearchIndex();
search.addIndex('title');
search.addIndex('author');
search.addDocuments(books);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Brian Vaughn on
  • Revision 2: published on
  • Revision 3: published by Brian Vaughn on
  • Revision 4: published by Brian Vaughn on
  • Revision 5: published by Brian Vaughn on