diff --git a/query/reverse.js b/query/reverse.js index be024072..95b788a3 100644 --- a/query/reverse.js +++ b/query/reverse.js @@ -33,8 +33,8 @@ function generateQuery( clean ){ // set radius, default to 500km if not specified in request var radius = 500; - if (clean.hasOwnProperty('boundary_circle_radius')) { - radius = clean.boundary_circle_radius; + if (clean.hasOwnProperty('boundary.circle.radius')) { + radius = clean['boundary.circle.radius']; } // focus point centroid diff --git a/query/search.js b/query/search.js index 0884298d..fff3c172 100644 --- a/query/search.js +++ b/query/search.js @@ -97,9 +97,9 @@ function generateQuery( clean ){ } // boundary country - if( clean.boundary && clean.boundary.country ){ + if( clean['boundary.country'] ){ vs.set({ - 'boundary:country': clean.boundary.country + 'boundary:country': clean['boundary.country'] }); } diff --git a/sanitiser/_geo_common.js b/sanitiser/_geo_common.js index 71b728cb..2ba50240 100644 --- a/sanitiser/_geo_common.js +++ b/sanitiser/_geo_common.js @@ -64,9 +64,9 @@ function sanitize_coord( coord, clean, param, latlon_is_required ) { */ function sanitize_boundary_circle( clean, params, is_required, all_required ) { var props = { - lat: 'boundary_circle_lat', - lon: 'boundary_circle_lon', - rad: 'boundary_circle_radius' + lat: 'boundary.circle.lat', + lon: 'boundary.circle.lon', + rad: 'boundary.circle.radius' }; // get values for each property diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index bb838626..d89568ae 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -24,7 +24,7 @@ module.exports.tests.query = function(test, common) { test('valid query with radius', function(t) { var query = generate({ - lat: 29.49136, lon: -82.50622, boundary_circle_radius: 123 + lat: 29.49136, lon: -82.50622, 'boundary.circle.radius': 123 }); var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.distance; @@ -38,8 +38,8 @@ module.exports.tests.query = function(test, common) { var clean = { lat: 29.49136, lon: -82.50622, - boundary_circle_lat: 111, - boundary_circle_long: 333 + 'boundary.circle.lat': 111, + 'boundary.circle.long': 333 }; var query = generate(clean); diff --git a/test/unit/query/search.js b/test/unit/query/search.js index b7b6ea9f..d595d1a7 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -138,7 +138,7 @@ module.exports.tests.query = function(test, common) { var query = generate({ text: 'test', size: 10, layers: ['test'], - boundary: { country: 'ABC' } + 'boundary.country': 'ABC' }); var compiled = JSON.parse( JSON.stringify( query ) ); diff --git a/test/unit/sanitiser/_geo_common.js b/test/unit/sanitiser/_geo_common.js index dc5b4823..8771e72c 100644 --- a/test/unit/sanitiser/_geo_common.js +++ b/test/unit/sanitiser/_geo_common.js @@ -23,11 +23,12 @@ module.exports.tests.sanitize = function(test, common) { var all_required = true; sanitize.sanitize_boundary_circle(clean, params, is_required, all_required); - t.equal(clean.boundary_circle_lat, params['boundary.circle.lat'], 'lat approved'); - t.equal(clean.boundary_circle_lon, params['boundary.circle.lon'], 'lon approved'); - t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved'); + t.equal(clean['boundary.circle.lat'], params['boundary.circle.lat'], 'lat approved'); + t.equal(clean['boundary.circle.lon'], params['boundary.circle.lon'], 'lon approved'); + t.equal(clean['boundary.circle.radius'], params['boundary.circle.radius'], 'radius approved'); t.end(); }); + test('valid circle, radius only, all not required', function (t) { var clean = {}; var params = { @@ -37,7 +38,7 @@ module.exports.tests.sanitize = function(test, common) { var all_required = false; sanitize.sanitize_boundary_circle(clean, params, is_required, all_required); - t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved'); + t.equal(clean['boundary.circle.radius'], params['boundary.circle.radius'], 'radius approved'); t.end(); }); };