mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Merge pull request #187 from keerthi16/SEARCH-155
Search 155 (Real time indexing)
This commit is contained in:
commit
f72e0b7db6
@ -122,7 +122,7 @@
|
||||
buttonIndex.addEventListener('click', function () {
|
||||
let batchIndex = batchNumber.value;
|
||||
search.readJson(batchIndex).then(function (res) {
|
||||
search.indexBatch(res).then(function () {
|
||||
search.indexBatch(JSON.stringify(res)).then(function () {
|
||||
resultsEl.innerHTML = "Index created";
|
||||
});
|
||||
}).catch(function (err) {
|
||||
@ -185,7 +185,7 @@
|
||||
|
||||
sendMessage.addEventListener('click', function () {
|
||||
if (realTimeIndexing.value !== "") {
|
||||
let message = JSON.parse(realTimeIndexing.value);
|
||||
let message = realTimeIndexing.value;
|
||||
resultsEl.innerHTML = search.realTimeIndexing(message);
|
||||
} else {
|
||||
resultsEl.innerHTML = "Please check the entered value"
|
||||
|
@ -109,7 +109,12 @@ class Search {
|
||||
*/
|
||||
indexBatch(messages) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!messages && !(JSON.parse(messages) instanceof Array)) {
|
||||
if (!messages) {
|
||||
reject(new Error('Messages is required'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(JSON.parse(messages) instanceof Array)) {
|
||||
reject(new Error('Messages must be an array'));
|
||||
return;
|
||||
}
|
||||
@ -151,15 +156,19 @@ class Search {
|
||||
* @param message
|
||||
*/
|
||||
realTimeIndexing(message) {
|
||||
if (!Array.isArray(message)) {
|
||||
return new Error('Messages should be an array');
|
||||
if (!message) {
|
||||
return new Error('Message is required');
|
||||
}
|
||||
|
||||
if (!(JSON.parse(message) instanceof Array)){
|
||||
return new Error('Message must be an array');
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user