diff --git a/client/application.js b/client/application.js index 25e3725..cb8f764 100644 --- a/client/application.js +++ b/client/application.js @@ -22,7 +22,7 @@ } ctx.grapher.setColumnHints(hintData); - outputResults(results.items, params.maxResults); + outputResults(results.items, results.count); }); } @@ -46,7 +46,7 @@ ctx.grapher.setColumns(results.columns); ctx.grapher.setValueChangedListener(onAdjust); - outputResults(results.items, params.maxResults); + outputResults(results.items, results.count); if (params.keywords) { $('#query').text(params.keywords.join(', ')); @@ -66,11 +66,14 @@ }); } - function outputResults(results, maxResults) { + function outputResults(results, count) { $('#results').empty(); - $('#count').text(results.length); - results = results.splice(0, maxResults); + var searchResultCnt = String(results.length); + if (results.length < count) { + searchResultCnt += ' of ' + count; + } + $('#count').text(searchResultCnt); var template = Handlebars.compile($('#template').html()); $('#results').append(template({'results': results})); diff --git a/server/db/search.js b/server/db/search.js index 40a95f2..c230a7c 100644 --- a/server/db/search.js +++ b/server/db/search.js @@ -45,7 +45,7 @@ function countData(searchParams, minScore) { return dataCount; } -function findData(searchParams, minScore, maxResults) { +function findData(searchParams, minScore) { var results = []; for (var i = 0, count = db_data.length; i < count; ++i) { @@ -71,7 +71,7 @@ function findData(searchParams, minScore, maxResults) { return b.score - a.score; }); - return results.slice(0, maxResults); + return results; } function searchStepper(range, steps, callback) { @@ -138,8 +138,7 @@ module.exports.execQuery = function(query) { var searchResults = findData( query.searchParams, - query.minScore * _.keys(query.searchParams).length, - query.maxResults + query.minScore * _.keys(query.searchParams).length ); var graphColumns = {}; @@ -163,6 +162,7 @@ module.exports.execQuery = function(query) { return { columns: graphColumns, params: query.searchParams, - items: searchResults + items: searchResults.slice(0, query.maxResults), + count: searchResults.length }; }