Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/improvement/KR-256-geolocation-s…
Browse files Browse the repository at this point in the history
…ort' into improvement/KR-248-worker-rewrite

Conflicts:
	lib/database/elasticsearch_adapter.js
  • Loading branch information
Razvan Botea committed Apr 25, 2016
2 parents 95136bd + 1d513c0 commit 9ff442d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/database/elasticsearch_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,19 @@ ElasticSearchDB.prototype.searchObjects = function(options, callback) {
}
});
} else {
if (options.sort)
reqBody.sort = options.sort;
if (sort) {
reqBody.sort = {};

if (!sort.type) {
reqBody.sort = [sort];
} else if (sort.type == 'default') {
reqBody.sort[sort.field] = sort.order;
} else if (sort.type == 'geo') {
reqBody.sort._geo_distance = {};
reqBody.sort._geo_distance[sort.field] = {lat: sort.poi.lat || 0.0, lon: sort.poi.long || 0.0};
reqBody.sort._geo_distance.order = sort.order;
}
}

this.connection.search({
index: this.config.index,
Expand Down

0 comments on commit 9ff442d

Please sign in to comment.