From 652a3389f3c9f2b439393d0d510fc2e9cb46cd84 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Tue, 5 Sep 2017 17:21:23 +0530 Subject: [PATCH] SEARCH-155 Index real-time data. - Read messages from data feed - Index the messages in real-time index. --- js/search/search.js | 7 ++++--- package.json | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 81ab1ec7..c8de6fd4 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -6,6 +6,7 @@ const electron = require('electron'); const childProcess = require('child_process'); const app = electron.app; const path = require('path'); +const isObject = require('lodash.isplainobject'); const isDevEnv = require('../utils/misc.js').isDevEnv; const isMac = require('../utils/misc.js').isMac; @@ -151,15 +152,15 @@ class Search { * @param message */ realTimeIndexing(message) { - if (!Array.isArray(message)) { - return new Error('Messages should be an array'); + if (!message && !isObject(JSON.parse(message))) { + return new Error('Messages must be an object'); } if (!this.isInitialized) { return new Error('Library not initialized'); } - let result = libSymphonySearch.symSEIndexRealTime(this.realTimeIndex, JSON.stringify(message)); + let result = libSymphonySearch.symSEIndexRealTime(this.realTimeIndex, [ message ]); return result === 0 ? "Successful" : result } diff --git a/package.json b/package.json index feceb943..85a8513e 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "ffi": "^2.2.0", "filesize": "^3.5.10", "keymirror": "0.1.1", + "lodash.isplainobject": "^4.0.6", "node-forge": "^0.7.1", "randomstring": "^1.1.5", "ref": "^1.3.4",