mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
[Search] Search term processing
The search term processor for ElasticSearch now removes extra spaces from inside of the search term (to avoid some ES errors).
This commit is contained in:
parent
32b58715c6
commit
495d8c9830
@ -77,13 +77,20 @@ define(
|
||||
|
||||
// Currently specific to elasticsearch
|
||||
function processSearchTerm(searchTerm) {
|
||||
// Shave any spaces off of the ends of the input
|
||||
var spaceIndex;
|
||||
|
||||
// Cut out any extra spaces
|
||||
while (searchTerm.substr(0, 1) === ' ') {
|
||||
searchTerm = searchTerm.substring(1, searchTerm.length);
|
||||
}
|
||||
while (searchTerm.substr(searchTerm.length - 1, 1) === ' ') {
|
||||
searchTerm = searchTerm.substring(0, searchTerm.length - 1);
|
||||
}
|
||||
spaceIndex = searchTerm.indexOf(' ');
|
||||
while (spaceIndex !== -1) {
|
||||
searchTerm = searchTerm.substring(0, spaceIndex) + searchTerm.substring(spaceIndex + 1, searchTerm.length);
|
||||
spaceIndex = searchTerm.indexOf(' ');
|
||||
}
|
||||
|
||||
if (isDefaultFormat(searchTerm)) {
|
||||
// Add fuzziness for completeness
|
||||
@ -100,7 +107,7 @@ define(
|
||||
// Processes results from the format that elasticsearch returns to
|
||||
// a list of objects in the format that mct-representation can use
|
||||
function processResults(rawResults, timestamp) {
|
||||
var results = rawResults.data.hits.hits,
|
||||
var results = rawResults.hits.hits,
|
||||
resultsLength = results.length,
|
||||
ids = [],
|
||||
scores = {},
|
||||
@ -177,9 +184,9 @@ define(
|
||||
return $http({
|
||||
method: "GET",
|
||||
url: esQuery
|
||||
}).then(function (rawResults) {
|
||||
}).success(function (data, status) {
|
||||
// ...then process the data
|
||||
return processResults(rawResults, timestamp);
|
||||
return processResults(data, timestamp);
|
||||
});
|
||||
} else {
|
||||
latestResults = [];
|
||||
|
@ -63,10 +63,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
message = {
|
||||
request: 'index'
|
||||
};
|
||||
return message;
|
||||
*/
|
||||
}
|
||||
|
||||
// Helper function for serach()
|
||||
|
Loading…
x
Reference in New Issue
Block a user