mirror of https://github.com/Requarks/wiki.git
9 changed files with 189 additions and 68 deletions
Split View
Diff Options
-
63agent.js
-
7config.sample.yml
-
19gulpfile.js
-
61models/entries.js
-
16models/git.js
-
40models/markdown.js
-
42models/search.js
-
1package.json
-
8server.js
@ -0,0 +1,42 @@ |
|||
"use strict"; |
|||
|
|||
var Promise = require('bluebird'), |
|||
_ = require('lodash'), |
|||
path = require('path'), |
|||
searchIndex = Promise.promisifyAll(require('search-index')), |
|||
stopWord = require('stopword'); |
|||
|
|||
/** |
|||
* Search Model |
|||
*/ |
|||
module.exports = { |
|||
|
|||
_si: null, |
|||
|
|||
/** |
|||
* Initialize Search model |
|||
* |
|||
* @param {Object} appconfig The application config |
|||
* @return {Object} Search model instance |
|||
*/ |
|||
init(appconfig) { |
|||
|
|||
let dbPath = path.resolve(ROOTPATH, appconfig.datadir.db, 'search-index'); |
|||
|
|||
this._si = searchIndex({ |
|||
deletable: true, |
|||
fieldedSearch: true, |
|||
indexPath: dbPath, |
|||
logLevel: 'error', |
|||
stopwords: stopWord.getStopwords(appconfig.lang).sort() |
|||
}, (err, si) => { |
|||
if(err) { |
|||
winston.error('Failed to initialize search-index.', err); |
|||
} |
|||
}); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
}; |
Write
Preview
Loading…
Cancel
Save