nodebb-plugin-search-elasticsearch
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -217,2 +217,4 @@ "use strict"; | ||
var query = { | ||
index: Elasticsearch.config.index_name, | ||
type: Elasticsearch.config.post_type, | ||
body: { | ||
@@ -245,3 +247,3 @@ query: { | ||
var payload = obj.hits.hits.map(function(result) { | ||
return result._id; | ||
return parseInt(result._id, 10); | ||
}); | ||
@@ -263,2 +265,6 @@ | ||
if (!term || !term.length) { | ||
return callback(null, []); | ||
} | ||
async.parallel({ | ||
@@ -380,20 +386,28 @@ mainPid: async.apply(topics.getTopicField, tid, 'mainPid'), | ||
// Make sure id is an integer | ||
if (_.isString(item.id)) { | ||
item.id = parseInt(item.id, 10); | ||
} | ||
if (item && item.id) { | ||
// Make sure id is an integer | ||
var itemId = parseInt(item.id, 10); | ||
item.id = itemId; | ||
// Action | ||
body.push({ | ||
index: { | ||
/*_index: Elasticsearch.config.index_name, */ // We'll set it in bulk() | ||
/*_type: Elasticsearch.config.post_type, */ // We'll set it in bulk() | ||
_id: item.id | ||
} | ||
}); | ||
// Action | ||
body.push({ | ||
index: { | ||
/*_index: Elasticsearch.config.index_name, */ // We'll set it in bulk() | ||
/*_type: Elasticsearch.config.post_type, */ // We'll set it in bulk() | ||
_id: itemId | ||
} | ||
}); | ||
// Document | ||
body.push(item); | ||
// Document | ||
body.push(item); | ||
} | ||
}); | ||
if (0 === body.length) { | ||
if (callback) { | ||
return callback(null); | ||
} | ||
return; | ||
} | ||
Elasticsearch.client.bulk({ | ||
@@ -530,2 +544,9 @@ body: body, | ||
], function(err, payload) { | ||
if (err) { | ||
return winston.error(err.message); | ||
} | ||
if (!payload) { | ||
return winston.warn('[plugins/elasticsearch] no payload for pid ' + topicObj.mainPid); | ||
} | ||
payload.title = topicObj.title; | ||
@@ -563,4 +584,6 @@ Elasticsearch.add(payload); | ||
for(var x=0,numPids=payload.length;x<numPids;x++) { | ||
if (payload[x].id === topicObj.mainPid) { | ||
payload[x].title = topicObj.title; | ||
if (payload[x]) { | ||
if (payload[x].id === topicObj.mainPid) { | ||
payload[x].title = topicObj.title; | ||
} | ||
} | ||
@@ -672,3 +695,6 @@ } | ||
}, []).filter(function(entry) { | ||
return entry.hasOwnProperty('id'); | ||
if (entry) { | ||
return entry.hasOwnProperty('id'); | ||
} | ||
return false; | ||
}); | ||
@@ -675,0 +701,0 @@ |
{ | ||
"name": "nodebb-plugin-search-elasticsearch", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Full-text searching using Elasticsearch", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64955
705