mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Search] Reduced term processing
Term processing may be unnecissary. Now it is limited to removed spcaes from the front and end.
This commit is contained in:
@ -31,7 +31,8 @@ define(
|
|||||||
|
|
||||||
// JSLint doesn't like underscore-prefixed properties,
|
// JSLint doesn't like underscore-prefixed properties,
|
||||||
// so hide them here.
|
// so hide them here.
|
||||||
var ID = "_id";
|
var ID = "_id",
|
||||||
|
SCORE = "_score";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The query service is responsible for creating an index
|
* The query service is responsible for creating an index
|
||||||
@ -204,6 +205,7 @@ define(
|
|||||||
searchTerm = searchTerm.substring(0, searchTerm.length - 1);
|
searchTerm = searchTerm.substring(0, searchTerm.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// 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) === '"') ||
|
||||||
@ -231,7 +233,9 @@ define(
|
|||||||
// Assume that the search term is for the name by default
|
// Assume that the search term is for the name by default
|
||||||
searchTerm = "name:" + searchTerm;
|
searchTerm = "name:" + searchTerm;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//console.log('processed serach term ', searchTerm);
|
||||||
return searchTerm;
|
return searchTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +245,7 @@ define(
|
|||||||
var results = rawResults.data.hits.hits,
|
var results = rawResults.data.hits.hits,
|
||||||
resultsLength = results.length,
|
resultsLength = results.length,
|
||||||
ids = [],
|
ids = [],
|
||||||
|
scores = [],
|
||||||
i;
|
i;
|
||||||
|
|
||||||
if (rawResults.data.hits.total > resultsLength) {
|
if (rawResults.data.hits.total > resultsLength) {
|
||||||
@ -253,6 +258,13 @@ define(
|
|||||||
ids.push(results[i][ID]);
|
ids.push(results[i][ID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the result objects' scores
|
||||||
|
for (i = 0; i < resultsLength; i += 1) {
|
||||||
|
scores.push(results[i][SCORE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log('scores', scores);
|
||||||
|
|
||||||
// Get the domain objects from their IDs
|
// Get the domain objects from their IDs
|
||||||
return objectService.getObjects(ids).then(function (objects) {
|
return objectService.getObjects(ids).then(function (objects) {
|
||||||
var output = [],
|
var output = [],
|
||||||
@ -305,7 +317,7 @@ define(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
// Takes a serach term and (optionally) the max number of results.
|
// Takes a serach term and (optionally) the max number of results.
|
||||||
query: queryFallback
|
query: queryElasticsearch
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user