Merge remote-tracking branch 'upstream/skynet' into SEARCH-444

This commit is contained in:
Keerthi Niranjan 2017-11-24 13:15:02 +05:30
commit 384b114670

View File

@ -115,20 +115,20 @@ class Search {
indexBatch(messages) {
return new Promise((resolve, reject) => {
if (!messages) {
log.send(logLevels.ERROR, 'Messages was not provided for batch indexing');
reject(new Error('Messages is required'));
log.send(logLevels.ERROR, 'Batch Indexing: Messages not provided');
reject(new Error('Batch Indexing: Messages is required'));
return;
}
try {
let msg = JSON.parse(messages);
if (!(msg instanceof Array)) {
log.send(logLevels.ERROR, 'Message must be an array batch indexing');
reject(new Error('Messages must be an array'));
log.send(logLevels.ERROR, 'Batch Indexing: Messages must be an array');
reject(new Error('Batch Indexing: Messages must be an array'));
return;
}
} catch(e) {
log.send(logLevels.ERROR, 'Batch indexing parse Error -> ' + e);
log.send(logLevels.ERROR, 'Batch Indexing: parse error -> ' + e);
reject(new Error(e));
return;
}
@ -142,7 +142,7 @@ class Search {
const indexId = randomString.generate(searchConfig.BATCH_RANDOM_INDEX_PATH_LENGTH);
libSymphonySearch.symSECreatePartialIndexAsync(this.batchIndex, indexId, messages, (err, res) => {
if (err) {
log.send(logLevels.ERROR, 'Error indexing the batch ->' + err);
log.send(logLevels.ERROR, 'Batch Indexing: error ->' + err);
reject(new Error(err));
return;
}
@ -193,20 +193,19 @@ class Search {
* @param message
*/
realTimeIndexing(message) {
if (!message) {
log.send(logLevels.ERROR, 'Error message not provided for real-time indexing');
return new Error('Message is required');
log.send(logLevels.ERROR, 'RealTime Indexing: Messages not provided');
return new Error('RealTime Indexing: Messages is required');
}
try {
let msg = JSON.parse(message);
if (!(msg instanceof Array)) {
log.send(logLevels.ERROR, 'Message must be an array real-time indexing');
return (new Error('Messages must be an array'));
log.send(logLevels.ERROR, 'RealTime Indexing: Messages must be an array real-time indexing');
return (new Error('RealTime Indexing: Messages must be an array'));
}
} catch(e) {
log.send(logLevels.ERROR, 'Real-time indexing parse Error -> ' + e);
log.send(logLevels.ERROR, 'RealTime Indexing: parse error -> ' + e);
return (new Error(e));
}
@ -219,7 +218,7 @@ class Search {
return libSymphonySearch.symSEIndexRealTimeAsync(this.realTimeIndex, message, (err, result) => {
this.isRealTimeIndexing = false;
if (err) {
log.send(logLevels.ERROR, 'Indexing the real-time data -> ' + err);
log.send(logLevels.ERROR, 'RealTime Indexing: error -> ' + err);
return new Error(err);
}
return result;
@ -309,18 +308,21 @@ class Search {
return;
}
let sd = new Date().getTime() - searchConfig.SEARCH_PERIOD_SUBTRACTOR;
let sd_time = searchConfig.MINIMUM_DATE;
if (startDate && startDate !== "" && typeof startDate === 'object') {
sd_time = new Date(startDate).getTime();
if (sd_time >= sd) {
sd_time = sd;
let searchPeriod = new Date().getTime() - searchConfig.SEARCH_PERIOD_SUBTRACTOR;
let startDateTime = searchPeriod;
if (startDate) {
startDateTime = new Date(parseInt(startDate, 10)).getTime();
if (!startDateTime || startDateTime < searchPeriod) {
startDateTime = searchPeriod;
}
}
let ed_time = searchConfig.MAXIMUM_DATE;
if (endDate && endDate !== "" && typeof endDate === 'object') {
ed_time = new Date(endDate).getTime();
let endDateTime = searchConfig.MAXIMUM_DATE;
if (endDate) {
let eTime = new Date(parseInt(endDate, 10)).getTime();
if (eTime) {
endDateTime = eTime;
}
}
if (!_limit && _limit === "" && typeof _limit !== 'number' && Math.round(_limit) !== _limit) {
@ -335,7 +337,7 @@ class Search {
_sortOrder = searchConfig.SORT_BY_SCORE;
}
const returnedResult = libSymphonySearch.symSESearch(this.indexFolderName, this.realTimeIndex, q, sd_time.toString(), ed_time.toString(), _offset, _limit, _sortOrder);
const returnedResult = libSymphonySearch.symSESearch(this.indexFolderName, this.realTimeIndex, q, startDateTime.toString(), endDateTime.toString(), _offset, _limit, _sortOrder);
try {
let ret = returnedResult.readCString();
resolve(JSON.parse(ret));