[Search] Comments

Updated the documentation.
This commit is contained in:
shale 2015-07-21 15:31:23 -07:00
parent 92df11acc1
commit 4191bc1ac3
4 changed files with 111 additions and 66 deletions

View File

@ -44,7 +44,7 @@ define(
var latestMergedResults = [],
lastMergeTimestamps = [];
// Remove extra objects that have the same ID
// Remove duplicate objects that have the same ID
function filterRepeats(results) {
var ids = [],
idToIndicies = {}, // 'dictionary' mapping IDs to a list of indicies
@ -104,6 +104,7 @@ define(
return results;
}
// For documentation, see updateResults below.
function updateResults() {
var newerResults = [],
providerTimestamps = [];
@ -123,17 +124,7 @@ define(
lastMergeTimestamps = providerTimestamps;
}
/**
* Sends a query to each of the providers, then updates the globl
* latestMergedResults accordingly.
*
* @param inputID The name of the ID property of the html text
* input where this funcion should find the search term.
* @param timestamp (optional) The time at which this function
* was called. This timestamp will be associated with the
* latest results list, which allows us to see if it has been
* updated. If not provided, this aggregator will.
*/
// For documentation, see sendQuery below.
function queryAll(inputID, timestamp) {
// If there's not a timestamp, make this time the timestamp
if (!timestamp) {
@ -151,18 +142,48 @@ define(
}
return {
/**
* Sends a query to each of the providers, then updates the global
* latestMergedResults accordingly.
*
* @param inputID The name of the ID property of the html text
* input where this funcion should find the search term.
* @param timestamp (optional) The time at which this function
* was called. This timestamp will be associated with the
* latest results list, which allows us to see if it has been
* updated. If not provided, this aggregator will.
*/
sendQuery: queryAll,
/**
* Updates the global latestMergedResults and lastMergeTimestamps
* by checking the latest results of each of the providers.
*/
updateResults: updateResults,
/**
* Get the latest search results that have been calculated. The
* format of the returned objects are searchResult objects, which
* have the members id, object, and score.
*
* @param start (optional) The index of latestMergedResults at
* which to start getting results.
* @param stop (optional) The index of latestMergedResults at
* which to stop getting results.
*/
getLatestResults: function (start, stop) {
// TODO: Make sure that slice handles out of bounds
// By default if there are no start or stop provided, will return
// the entire thing.
var a = latestMergedResults.slice(start, stop);
return a;
return latestMergedResults.slice(start, stop);
},
/**
* Get the timestamps for each of the provider's last controbutions
* to the latestMergedResults.
*/
getLatestTimestamps: function () {
var b = lastMergeTimestamps;
return b;
return lastMergeTimestamps;
}
};
}

View File

@ -49,7 +49,6 @@ define(function () {
if (areOld) {
// Then wait and try to update again
searchService.updateResults();
var latest = searchService.getLatestResults(0, numResults);
$timeout(waitForLatest, 100);
} else {
// We got the latest results now
@ -60,10 +59,17 @@ define(function () {
}
return {
// Search the database using the user input of id "searchinput"
/**
* Search the filetree.
*
* @param inputID The name of the ID property of the html text
* input where this funcion should find the search term.
*/
search: search,
// Check to see if there are any search results to display.
/**
* Checks to see if there are any search results to display.
*/
areResults: function () {
if ($scope.results) {
return $scope.results.length > 0;

View File

@ -144,29 +144,7 @@ define(
});
}
/**
* Searches through the filetree for domain objects using a search
* term. This is done through querying elasticsearch.
* Notes:
* * The order of the results is from highest to lowest score,
* as elsaticsearch determines them to be.
* * Wildcards are supported.
* * Fuzziness is used to produce more results that are still
* relevant. (All results within a certain edit distance.)
* * More search details at
* https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html
*
* @param inputID the name of the ID property of the html text
* input where this funcion should find the search term
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results
* list, which allows the aggregator to see if it has been
* updated
* @param maxResults (optional) the maximum number of results
* that this function should return
* @param timeout (optional) the time after which the search should
* stop calculations and return partial results
*/
// For documentation, see query below.
function queryElasticsearch(inputID, timestamp, maxResults, timeout) {
var searchTerm,
esQuery;
@ -202,12 +180,43 @@ define(
}
return {
/**
* Searches through the filetree for domain objects using a search
* term. This is done through querying elasticsearch.
* Notes:
* * The order of the results is from highest to lowest score,
* as elsaticsearch determines them to be.
* * Wildcards are supported.
* * Fuzziness is used to produce more results that are still
* relevant. (All results within a certain edit distance.)
* * More search details at
* https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html
*
* @param inputID the name of the ID property of the html text
* input where this funcion should find the search term
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results
* list, which allows the aggregator to see if it has been
* updated
* @param maxResults (optional) the maximum number of results
* that this function should return
* @param timeout (optional) the time after which the search should
* stop calculations and return partial results
*/
query: queryElasticsearch,
/**
* Get the latest search results that have been calculated. The
* format of the returned objects are searchResult objects, which
* have the members id, object, and score.
*/
getLatestResults: function () {
return latestResults;
},
/**
* Get the timestamp for the last update of latestResults.
*/
getLatestTimestamp: function () {
return lastSearchTimestamp;
}

View File

@ -145,30 +145,7 @@ define(
});
}
/**
* Searches through the filetree for domain objects which match
* the search term. This function is to be used as a fallback
* in the case where other search services are not avaliable.
* Notes:
* * The order of the results is not guarenteed.
* * A domain object qualifies as a match for a search input if
* the object's name property contains any of the search terms
* (which are generated by splitting the input at spaces).
* * Scores are higher for matches that have more than one of
* the terms as substrings.
* * Wildcards are not (yet?) supported.
*
* @param inputID the name of the ID property of the html text
* input where this funcion should find the search term
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results
* list, which allows the aggregator to see if it has been
* updated
* @param maxResults (optional) the maximum number of results
* that this function should return
* @param timeout (optional) the time after which the search should
* stop calculations and return partial results
*/
// For documentation, see query below.
function queryGeneric(inputID, timestamp, maxResults, timeout) {
var input,
terms = [],
@ -194,12 +171,44 @@ define(
}
return {
/**
* Searches through the filetree for domain objects which match
* the search term. This function is to be used as a fallback
* in the case where other search services are not avaliable.
* Notes:
* * The order of the results is not guarenteed.
* * A domain object qualifies as a match for a search input if
* the object's name property contains any of the search terms
* (which are generated by splitting the input at spaces).
* * Scores are higher for matches that have more than one of
* the terms as substrings.
* * Wildcards are not (yet?) supported.
*
* @param inputID the name of the ID property of the html text
* input where this funcion should find the search term
* @param timestamp the time at which this function was called,
* this timestamp will be associated with the latest results
* list, which allows the aggregator to see if it has been
* updated
* @param maxResults (optional) the maximum number of results
* that this function should return
* @param timeout (optional) the time after which the search should
* stop calculations and return partial results
*/
query: queryGeneric,
/**
* Get the latest search results that have been calculated. The
* format of the returned objects are searchResult objects, which
* have the members id, object, and score.
*/
getLatestResults: function () {
return latestResults;
},
/**
* Get the timestamp for the last update of latestResults.
*/
getLatestTimestamp: function () {
return lastSearchTimestamp;
}