chore: move search-indexing, supress webpack-cli progress (#39367)
This commit is contained in:
committed by
GitHub
parent
6e16a50329
commit
adef746299
40
tools/search-indexing/data-push/init/challenges.js
Normal file
40
tools/search-indexing/data-push/init/challenges.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const { client } = require('../../algolia');
|
||||
const debug = require('debug');
|
||||
const getChallengeData = require('../../data-sources/challenges');
|
||||
|
||||
const log = debug('fcc:search:init:challenge');
|
||||
|
||||
const index = client.initIndex('challenge');
|
||||
|
||||
index.setSettings(
|
||||
{
|
||||
searchableAttributes: ['title', 'description', 'blockName'],
|
||||
distinct: true,
|
||||
attributeForDistinct: 'id',
|
||||
attributesForFaceting: ['blockName']
|
||||
},
|
||||
(err, response) => {
|
||||
if (err) {
|
||||
log(err.message);
|
||||
log(err.debugData);
|
||||
throw new Error(err);
|
||||
}
|
||||
log('setSettings\n\n' + JSON.stringify(response, null, 2));
|
||||
}
|
||||
);
|
||||
|
||||
exports.insertChallenges = function insertChallenges() {
|
||||
return getChallengeData().subscribe(
|
||||
challenges => {
|
||||
index.addObjects(challenges, err => {
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
err => {
|
||||
throw new Error(err);
|
||||
},
|
||||
() => log('complete')
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user