From 37525246d23fcb98cd8322e7e87fc1339a47a9b3 Mon Sep 17 00:00:00 2001 From: Razvan Botea Date: Thu, 28 Apr 2016 14:09:56 +0300 Subject: [PATCH] Fix searchObjects when geolocation sorting is used --- lib/database/elasticsearch_adapter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/database/elasticsearch_adapter.js b/lib/database/elasticsearch_adapter.js index 32e706c..9c5c82e 100644 --- a/lib/database/elasticsearch_adapter.js +++ b/lib/database/elasticsearch_adapter.js @@ -254,7 +254,7 @@ ElasticSearchDB.prototype.searchObjects = function(options, callback) { reqBody.sort[options.sort.field] = options.sort.order; } else if (options.sort.type == 'geo') { reqBody.sort._geo_distance = {}; - reqBody.sort._geo_distance[options.sort.field] = {lat: sort.poi.lat || 0.0, lon: options.sort.poi.long || 0.0}; + reqBody.sort._geo_distance[options.sort.field] = {lat: options.sort.poi.lat || 0.0, lon: options.sort.poi.long || 0.0}; reqBody.sort._geo_distance.order = options.sort.order; } } @@ -264,8 +264,7 @@ ElasticSearchDB.prototype.searchObjects = function(options, callback) { type: options.modelName, body: reqBody, from: options.offset, - size: options.limit, - search_type: options.sort + size: options.limit }, function(err, results) { if (err) return callback(err);