mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +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:
@ -77,13 +77,20 @@ define(
|
|||||||
|
|
||||||
// Currently specific to elasticsearch
|
// Currently specific to elasticsearch
|
||||||
function processSearchTerm(searchTerm) {
|
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) === ' ') {
|
while (searchTerm.substr(0, 1) === ' ') {
|
||||||
searchTerm = searchTerm.substring(1, searchTerm.length);
|
searchTerm = searchTerm.substring(1, searchTerm.length);
|
||||||
}
|
}
|
||||||
while (searchTerm.substr(searchTerm.length - 1, 1) === ' ') {
|
while (searchTerm.substr(searchTerm.length - 1, 1) === ' ') {
|
||||||
searchTerm = searchTerm.substring(0, searchTerm.length - 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)) {
|
if (isDefaultFormat(searchTerm)) {
|
||||||
// Add fuzziness for completeness
|
// Add fuzziness for completeness
|
||||||
@ -100,7 +107,7 @@ define(
|
|||||||
// Processes results from the format that elasticsearch returns to
|
// Processes results from the format that elasticsearch returns to
|
||||||
// a list of objects in the format that mct-representation can use
|
// a list of objects in the format that mct-representation can use
|
||||||
function processResults(rawResults, timestamp) {
|
function processResults(rawResults, timestamp) {
|
||||||
var results = rawResults.data.hits.hits,
|
var results = rawResults.hits.hits,
|
||||||
resultsLength = results.length,
|
resultsLength = results.length,
|
||||||
ids = [],
|
ids = [],
|
||||||
scores = {},
|
scores = {},
|
||||||
@ -177,9 +184,9 @@ define(
|
|||||||
return $http({
|
return $http({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: esQuery
|
url: esQuery
|
||||||
}).then(function (rawResults) {
|
}).success(function (data, status) {
|
||||||
// ...then process the data
|
// ...then process the data
|
||||||
return processResults(rawResults, timestamp);
|
return processResults(data, timestamp);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
latestResults = [];
|
latestResults = [];
|
||||||
|
@ -63,10 +63,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
message = {
|
message = {
|
||||||
request: 'index'
|
request: 'index'
|
||||||
};
|
};
|
||||||
return message;
|
return message;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for serach()
|
// Helper function for serach()
|
||||||
|
Reference in New Issue
Block a user