[Search] Readded ElasticSearch provider

Previously had removed the elasticsearch provider
from bundle.json so could work on the generic
search web worker. Now have modified the
elasticsearch provider to match the new interface
with the aggregator, and it works.

At this point, search is 'working'
This commit is contained in:
shale 2015-07-21 15:14:07 -07:00
parent 416bd82589
commit 92df11acc1
3 changed files with 22 additions and 8 deletions

View File

@ -44,6 +44,12 @@
"implementation": "providers/GenericSearchProvider.js",
"depends": [ "$rootScope", "objectService", "workerService" ]
},
{
"provides": "searchService",
"type": "provider",
"implementation": "providers/ElasticsearchSearchProvider.js",
"depends": [ "$http", "objectService", "ELASTIC_ROOT" ]
},
{
"provides": "searchService",
"type": "aggregator",

View File

@ -40,13 +40,15 @@ define(
* the filetree using ElasticSearch.
*
* @constructor
* @param $http Angular's $http service, for working with urls
* @param $http Angular's $http service, for working with urls.
* @param {ObjectService} objectService the service from which
* domain objects can be gotten.
* @param ROOT the constant ELASTIC_ROOT which allows us to
* interact with ElasticSearch.
*/
function ElasticsearchSearchProvider($http, objectService, ROOT) {
var latestResults = [],
lastSearchTimestamp = 0;
// Check to see if the input has any special options
function isDefaultFormat(searchTerm) {
@ -97,7 +99,7 @@ define(
// Processes results from the format that elasticsearch returns to
// a list of objects in the format that mct-representation can use
function processResults(rawResults) {
function processResults(rawResults, timestamp) {
var results = rawResults.data.hits.hits,
resultsLength = results.length,
ids = [],
@ -122,7 +124,6 @@ define(
// Get the domain objects from their IDs
return objectService.getObjects(ids).then(function (objects) {
// Filter by search term
for (var j = 0; j < resultsLength; j += 1) {
var id = ids[j];
@ -137,7 +138,8 @@ define(
}
}
//console.log('searchResults (in ES provider)', searchResults);
latestResults = searchResults;
lastSearchTimestamp = timestamp;
return searchResults;
});
}
@ -195,12 +197,20 @@ define(
url: esQuery
}).then(function (rawResults) {
// ...then process the data
return processResults(rawResults);
return processResults(rawResults, timestamp);
});
}
return {
query: queryElasticsearch
query: queryElasticsearch,
getLatestResults: function () {
return latestResults;
},
getLatestTimestamp: function () {
return lastSearchTimestamp;
}
};
}

View File

@ -78,7 +78,6 @@
// Then split it at the spaces
terms = terms.split(' ');
console.log('terms', terms);
return terms;
}
@ -136,7 +135,6 @@
results[indexedItems[i].id] = {
score: score
};
console.log(results[indexedItems[i].id]);
}
}