-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
32 lines (27 loc) · 1.07 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script src="lunr.js"></script>
<script src="lunr.autocomplete.js"></script>
<script>
// some docs…
var docs =
[
{
"id" : "1",
"title" : "The Hunting of the Snark",
"content" : "A map showing where to find the deadly snark, hidden amidst bandersnatch, beamish, frumious, galumphing, jubjub, mimsiest, outgrabe and uffish. Held by a bellman, this map is considered equally useful wherever one is. It has been used to successfully find the creature once, although the discoverer, a baker, vanished without a trace. He left behind friends such as a beaver, butcher, and boots."
},
{
"id" : "2",
"title" : "Jabberwocky",
"content" : "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!"
}
];
// setting up the index
var idx = lunr(function () {
this.field('title');
this.field('content');
this.use(lunr.autocomplete, 4);
});
// loading the documents into the index
docs.forEach(function (doc) { idx.add(doc) });
console.log(idx.autocomplete("jabberwock"));
</script>