[Search] Moved hard coding

Moved where the search type is
prepended to the search term, to
allow future changes to it.
This commit is contained in:
shale 2015-07-14 12:39:00 -07:00
parent 7c627fae8f
commit 27c7410318

View File

@ -144,7 +144,7 @@ define(
// Allow exact searches by checking to see if the first and last // Allow exact searches by checking to see if the first and last
// chars are quotes. // chars are quotes.
if ((searchTerm.substr(0, 1) === '"' && searchTerm.substr(searchTerm.length - 1, 1) === '"') || if ((searchTerm.substr(0, 1) === '"' && searchTerm.substr(searchTerm.length - 1, 1) === '"') ||
(searchTerm.substr(0, 1) === "'" && searchTerm.substr(searchTerm.length - 1, 1) === "'")) { (searchTerm.substr(0, 1) === "'" && searchTerm.substr(searchTerm.length - 1, 1) === "'")) {
// Remove the quotes, because of how elasticsearch processses. // Remove the quotes, because of how elasticsearch processses.
// This will mean that elasticsearch will return any object that has // This will mean that elasticsearch will return any object that has
// that searchTerm as a part of the name _separated by spaces_. // that searchTerm as a part of the name _separated by spaces_.
@ -158,11 +158,13 @@ define(
// '*sine* OR *telemetry*' // '*sine* OR *telemetry*'
searchTerm = '*' + searchTerm + '*'; searchTerm = '*' + searchTerm + '*';
} }
// Assume that the search term is for the name by default
searchTerm = "name:" + searchTerm;
// Get the data... // Get the data...
return $http({ return $http({
method: "GET", method: "GET",
url: ROOT + "/_search/?q=name:" + searchTerm + url: ROOT + "/_search/?q=" + searchTerm +
"&size=" + maxResults "&size=" + maxResults
}).then(function (rawResults) { }).then(function (rawResults) {
// ...then process the data // ...then process the data