HTML Preparation code:
x
 
1
<script src="https://unpkg.com/lunr/lunr.js"></script>
2
<script type="text/javascript" src="https://rawgit.com/bvaughn/js-search/1.2.0/dist/js-search.js"></script>
3
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/minisearch@2.2.2/dist/umd/index.min.js"></script>
4
<script>
5
6
        Benchmark.prototype.setup = function() {
7
8
          
9
  var books = [];
10
  var xmlhttp = new XMLHttpRequest();
11
  xmlhttp.onreadystatechange = function() {
12
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
13
      var json = JSON.parse(xmlhttp.responseText);
14
  
15
      books = json.books;
16
    }
17
  }
18
  xmlhttp.open('GET', 'http://bvaughn.github.io/js-search/books.json', true);
19
  xmlhttp.send();
20
21
        
22
  };
23
24
25
      
26
</script>
Tests:
  • Lunr

     
    var idx = lunr(function () {
      this.ref('isbn');
      this.field('title');
      this.field('author');
      books.forEach(function (doc) {
        this.add(doc)
      }, this);
    })
  • js search

     
    var search = new JsSearch.Search('isbn');
    search.searchIndex = new JsSearch.TfIdfSearchIndex('isbn');
    search.addIndex('title');
    search.addIndex('author');
    search.addDocuments(books);
  • minisearch

     
    var miniSearch = new MiniSearch({
      fields: ['isbn', 'title', 'author'], // fields to index for full-text search
    });
    miniSearch.addAll(books)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lunr
    js search
    minisearch

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one month ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Windows
View result in a separate tab
Test name Executions per second
Lunr 2600294.2 Ops/sec
js search 22075126.0 Ops/sec
minisearch 1373556.4 Ops/sec