Navigation Menu

Skip to content

Commit

Permalink
Specify all options in handler
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 21, 2012
1 parent 451479d commit c64605a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/server.js
Expand Up @@ -30,14 +30,7 @@ app.use(function(error, request, response, next){

// helpers
function search(options, callback) {
var searchOptions = {
size: options.size,
facet: 'path',
q: options.query,
start: options.start
}

var url = 'http://' + searchNode + '/2011-02-01/search?' + querystring.stringify(searchOptions);
var url = 'http://' + searchNode + '/2011-02-01/search?' + querystring.stringify(options);
console.log(url);
var buffer = '';
var request = http.get(url, function(response) {
Expand Down Expand Up @@ -83,9 +76,10 @@ app.get('/', function(request, response){

app.get('/search', function(request, response, next) {
var options = {
query: request.query.query,
q: request.query.query,
start: parseInt((request.query.start || '0'), 10),
size: 100
size: 100,
facet: 'path'
};

console.log('SEARCH', options);
Expand All @@ -102,21 +96,21 @@ app.get('/search', function(request, response, next) {

if (nextStart < numFound) {
nextLink = urlForSearch({
query: options.query,
query: options.q,
start: nextStart
});
}
if (previousStart >= 0) {
previousLink = urlForSearch({
query: options.query,
query: options.q,
start: previousStart
});
}

var locals = {
urlForSearch: urlForSearch,
titleToId: titleToId,
query: options.query,
query: options.q,
records: results.hits.hit,
numFound: numFound,
pathFacets: results.facets.path.constraints,
Expand Down

0 comments on commit c64605a

Please sign in to comment.