New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nodebb-plugin-search-elasticsearch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodebb-plugin-search-elasticsearch - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

93

library.js

@@ -16,2 +16,3 @@ "use strict";

posts = module.parent.require('./posts'),
batch = module.parent.require('./batch'),

@@ -36,3 +37,4 @@ escapeSpecialChars = function(s) {

index_name: 'nodebb',
post_type: 'posts'
post_type: 'posts',
batch_size: 1000
}, // default is localhost:9200

@@ -663,4 +665,3 @@ client: undefined

async.series([
Elasticsearch.deleteIndex,
Elasticsearch.createIndex
Elasticsearch.deleteIndex
],

@@ -674,68 +675,36 @@ function(err, results){

async.waterfall([
async.apply(db.getSortedSetRange, 'topics:tid', 0, -1),
function(tids, next) {
topics.getTopicsFields(tids, ['tid', 'mainPid', 'title'], next);
}
], function(err, topics) {
if (err) {
return winston.error('[plugins/elasticsearch] Could not retrieve topic listing for indexing. Error: ' + err.message);
}
batch.processSortedSet('topics:tid', function(tids, next) {
topics.getTopicsFields(tids, ['tid', 'mainPid', 'title'], function(err, topics) {
if (err) {
return next(err);
}
async.map(topics, Elasticsearch.indexTopic, function(err, topicPayloads) {
var payload = topicPayloads.reduce(function(currentPayload, topics) {
if (Array.isArray(topics)) {
return currentPayload.concat(topics);
} else {
currentPayload.push(topics);
}
}, []).filter(function(entry) {
if (entry) {
return entry.hasOwnProperty('id');
}
return false;
});
async.map(topics, Elasticsearch.indexTopic, function(err, topicPayloads) {
var payload = topicPayloads.reduce(function(currentPayload, topics) {
if (Array.isArray(topics)) {
return currentPayload.concat(topics);
} else {
currentPayload.push(topics);
}
}, []).filter(function(entry) {
if (entry) {
return entry.hasOwnProperty('id');
}
return false;
});
Elasticsearch.add(payload, function(err, obj) {
if (err) {
return next(err);
}
Elasticsearch.add(payload, function(err, obj) {
if (!err) {
res.sendStatus(200);
}
next();
});
});
});
});
});
};
Elasticsearch.createIndex = function(callback) {
if (!Elasticsearch.client) {
return callback(new Error('not-connected'));
}
var indexName = Elasticsearch.config.index_name;
if (indexName && 0 < indexName.length) {
Elasticsearch.client.indices.create({
index : Elasticsearch.config.index_name,
body: {
mappings: {
posts: {
properties : {
content : { type : "string" }, // Post content
title : { type : "string" } // Topic title
}
}
}
}
}, function(err, results){
}, {batch: parseInt(Elasticsearch.config.batch_size, 10)}, function(err) {
if (!err) {
callback(null, results);
res.sendStatus(200);
}
else if ( /IndexAlreadyExistsException/im.test(err.message) ) { // we can ignore if index is already there
winston.info("[plugin/elasticsearch] Ignoring error creating mapping " + err);
callback(null);
}
else {
callback(err);
}
});
}
});
};

@@ -742,0 +711,0 @@

{
"name": "nodebb-plugin-search-elasticsearch",
"version": "0.1.2",
"version": "0.1.3",
"description": "Full-text searching using Elasticsearch",

@@ -5,0 +5,0 @@ "main": "library.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc