Skip to content

Instantly share code, notes, and snippets.

View samdutton's full-sized avatar

Sam Dutton samdutton

View GitHub Profile
@samdutton
samdutton / index.json
Last active February 1, 2018 23:38
Lunr index snippet
{
"index": {
"title": {
"root": {
"9": {
"8": {
"docs": {
"98+Short+Sleeve+Tee": {
"tf": 1
},
@samdutton
samdutton / index.js
Created February 2, 2018 00:36
Create Elasticlunr search index
// node index.js
// get documents to be indexed.
const docs = getDocs();
const index = elasticlunr(function() {
// Set fields to index.
this.addField('name');
this.addField('description');
// Set the field used to identify documents.
this.setRef('id');
@samdutton
samdutton / main.js
Created February 2, 2018 00:38
Get Elasticlunr index file
// main.js running on the user's browser
fetch('data/index.json').then(response => {
return response.json();
}).then(json => {
index = elasticlunr.Index.load(json);
});
@samdutton
samdutton / main.js
Created February 2, 2018 00:39
Search with Elasticlunr
const matches = index.search(‘foo’);
@samdutton
samdutton / index.json
Last active February 2, 2018 01:30
Lunr search index
{
"index": {
"title": {
"root": {
"9": {
"8": {
"docs": {
"98+Short+Sleeve+Tee": {
"tf": 1
},
@samdutton
samdutton / sample.vtt
Created February 2, 2018 01:52
Sample WebVTT caption file
WEBVTT
00:00:00.500 --> 00:00:02.000
The Web is always changing
00:00:02.500 --> 00:00:04.300
and the way we access it is changing