diff --git a/lib/search.js b/lib/search.js index 94af89a..5527599 100644 --- a/lib/search.js +++ b/lib/search.js @@ -4,6 +4,7 @@ export default class Searcher{ constructor(fileArr, fields){ this.distance = parseFloat(process.env.FUZZY_DISTANCE) this.minMatch = parseFloat(process.env.MIN_MATCH) + this.indexing = false this.createIndex(fileArr, fields) } @@ -36,10 +37,12 @@ export default class Searcher{ else{ this.miniSearch.removeAll() } + this.indexing = true this.miniSearch.addAllAsync(fileArr) .then( result => { console.log('File list indexing completed.') console.log(`Total terms in index: ${this.miniSearch.termCount}`) + this.indexing = false }) } parseHrtimeToSeconds(hrtime){ diff --git a/server.js b/server.js index 3339e56..54775ef 100644 --- a/server.js +++ b/server.js @@ -107,7 +107,8 @@ app.get("/settings", function(req, res) { res.render('pages/index', { page: 'settings', crawlTime: crawlTime, - defaultSettings: defaultSettings + defaultSettings: defaultSettings, + indexing: search.indexing }) }) diff --git a/views/pages/results.ejs b/views/pages/results.ejs index a885aad..5f09889 100644 --- a/views/pages/results.ejs +++ b/views/pages/results.ejs @@ -14,7 +14,7 @@ _ / / / _ /_/ /_ / _ / / __/ / / / /_ -
Found <%= results.items.length %> result<%= results.items.length != 1 ? 's': '' %> in <%= results.elapsed %> seconds. <%= results.elapsed > 10 ? ' Lucky you, you caught the indexer while it was running.' : '' %>
+Found <%= results.items.length %> result<%= results.items.length != 1 ? 's': '' %> in <%= results.elapsed %> seconds. <%= indexing ? "Indexing in progress, if the list is missing something please try reloading in a few minutes" : "" %>