Improvements to autocomplete functionality

-- Array is now clensed of null and duplicate values and returned in a flat array for ease of use.
This commit is contained in:
Wallermadev 2017-09-20 03:17:11 +01:00
parent 17ee066134
commit c6fab81e61
2 changed files with 15 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -94,9 +94,21 @@ class LighthouseControllers {
let results = result.hits.hits;
let cResults = [];
for (let pResult of results) {
cResults.push(pResult._source);
cResults.push(pResult._source.name);
if(pResult._source.value !== undefined){
cResults.push(pResult._source.value.stream.metadata.title);
cResults.push(pResult._source.value.stream.metadata.author);
}
ctx.body = cResults;
}
var clean = new Array();
for (var i = 0; i < cResults.length; i++) {
if (cResults[i] && cResults[i].length > 3 && clean.indexOf(cResults[i]) == -1) {
clean.push(cResults[i]);
}
}
ctx.body = clean;
});
}
/**