From 245abd78091176c950d2a8535425026f9e3d3c16 Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Tue, 23 Dec 2014 11:36:06 -0500 Subject: [PATCH] elasticsearch-backend now only accepts vertices and not latlon as properties --- sanitiser/_latlonzoom.js | 7 ++++++- test/unit/query/search.js | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/sanitiser/_latlonzoom.js b/sanitiser/_latlonzoom.js index 0854d891..fd720cfe 100644 --- a/sanitiser/_latlonzoom.js +++ b/sanitiser/_latlonzoom.js @@ -57,7 +57,12 @@ function sanitize( req ){ } }); if (bbox.length === 4) { - clean.bbox = bbox; + clean.bbox = { + top : bbox[0], + right : bbox[1], + bottom: bbox[2], + left : bbox[3] + }; } else { return { 'error': true, diff --git a/test/unit/query/search.js b/test/unit/query/search.js index d4fdefc6..610223c6 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -15,7 +15,12 @@ module.exports.tests.query = function(test, common) { var query = generate({ input: 'test', size: 10, lat: 29.49136, lon: -82.50622, - bbox: [47.47, -61.84, 11.51, -103.16], + bbox: { + top: 47.47, + right: -61.84, + bottom: 11.51, + left: -103.16 + }, // bbox: { //TODO write a test where no bbox is provided // bottom_left: { // lat: 11.51053655297385, @@ -47,15 +52,12 @@ module.exports.tests.query = function(test, common) { { 'geo_bounding_box': { 'center_point': { - 'top_right': { - 'lat': '47.47', - 'lon': '-61.84' - }, - 'bottom_left': { - 'lat': '11.51', - 'lon': '-103.16' - } - } + 'top': '47.47', + 'right': '-61.84', + 'bottom':'11.51', + 'left': '-103.16' + }, + '_cache': true } } ] @@ -66,7 +68,7 @@ module.exports.tests.query = function(test, common) { 'sort': [], 'size': 10 }; - + console.log(JSON.stringify(query, 2, null)); t.deepEqual(query, expected, 'valid search query'); t.end(); });