Full Text Indexing in the Browser
Only Half As Bad As You Might Think!
...actually a talk about Web Workers
Why do it in the browser?
Full Text Searching
Web Workers!
Full Text Searching
💥 With Web Worker 💥
Â
import FullTextSearch from 'full-text-search-light'
let index
function initializeIndex (beerData) {
index = new FullTextSearch()
beerData.forEach(beer => index.add(beer))
postMessage('indexed')
}
searchworker.js
import FullTextSearch from 'full-text-search-light'
onmessage = message => {
const payload = message.data
const messageType = payload.messageType
switch (messageType) {
case 'init':
initializeIndex(payload.beerData)
return
default: return
}
}
let index
function initializeIndex (beerData) {
index = new FullTextSearch()
beerData.forEach(beer => index.add(beer))
postMessage('indexed')
}
searchworker.js
import FullTextSearch from 'full-text-search-light'
let index
function initializeIndex (beerData) {
index = new FullTextSearch()
beerData.forEach(beer => index.add(beer))
postMessage('indexed')
}
app.js