mirror of
https://github.com/nasa/openmct.git
synced 2025-01-20 11:38:56 +00:00
[Search] Relaxed quote rules
Allowed quotes more often in search terms. When there are quotes, that space-separated term will not get the fuzzy identifier.
This commit is contained in:
parent
672fa74321
commit
c5c3546b92
@ -149,10 +149,12 @@ define(
|
||||
// Used by queryElasticsearch()
|
||||
function isDefaultInput(searchTerm) {
|
||||
// If the input has quotes, not default
|
||||
/*
|
||||
if ((searchTerm.substr(0, 1) === '"' && searchTerm.substr(searchTerm.length - 1, 1) === '"') ||
|
||||
(searchTerm.substr(0, 1) === "'" && searchTerm.substr(searchTerm.length - 1, 1) === "'")) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
// If the input has a property option, not default
|
||||
if (searchTerm.includes('name:') || searchTerm.includes('type:')) {
|
||||
@ -170,7 +172,12 @@ define(
|
||||
}
|
||||
|
||||
return searchTerm.split(' ').map(function (s) {
|
||||
return s + '~' + editDistance;
|
||||
if (s.includes('"')) {
|
||||
console.log('true');
|
||||
return s;
|
||||
} else {
|
||||
return s + '~' + editDistance;
|
||||
}
|
||||
}).join(' ');
|
||||
}
|
||||
|
||||
@ -187,12 +194,13 @@ define(
|
||||
|
||||
if (isDefaultInput(searchTerm)) {
|
||||
// Add fuzziness for completeness
|
||||
searchTerm = addFuzziness(searchTerm, 2);
|
||||
searchTerm = addFuzziness(searchTerm);
|
||||
|
||||
// Searching 'name' by default
|
||||
searchTerm = 'name:' + searchTerm;
|
||||
}
|
||||
|
||||
console.log('search term ', searchTerm);
|
||||
return searchTerm;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user