|
|
@ -12,7 +12,7 @@ module.exports.tests.interface = function(test, common) { |
|
|
|
module.exports.tests.query = function(test, common) { |
|
|
|
module.exports.tests.query = function(test, common) { |
|
|
|
test('valid query', function(t) { |
|
|
|
test('valid query', function(t) { |
|
|
|
var query = generate({ |
|
|
|
var query = generate({ |
|
|
|
lat: 29.49136, lon: -82.50622 |
|
|
|
'point.lat': 29.49136, 'point.lon': -82.50622 |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
@ -24,7 +24,7 @@ module.exports.tests.query = function(test, common) { |
|
|
|
|
|
|
|
|
|
|
|
test('valid query with radius', function(t) { |
|
|
|
test('valid query with radius', function(t) { |
|
|
|
var query = generate({ |
|
|
|
var query = generate({ |
|
|
|
lat: 29.49136, lon: -82.50622, 'boundary.circle.radius': 123 |
|
|
|
'point.lat': 29.49136, 'point.lon': -82.50622, 'boundary.circle.radius': 123 |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.distance; |
|
|
|
var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.distance; |
|
|
@ -36,15 +36,15 @@ module.exports.tests.query = function(test, common) { |
|
|
|
|
|
|
|
|
|
|
|
test('valid query with boundary.circle lat/lon/radius', function(t) { |
|
|
|
test('valid query with boundary.circle lat/lon/radius', function(t) { |
|
|
|
var clean = { |
|
|
|
var clean = { |
|
|
|
lat: 29.49136, |
|
|
|
'point.lat': 29.49136, |
|
|
|
lon: -82.50622, |
|
|
|
'point.lon': -82.50622, |
|
|
|
'boundary.circle.lat': 111, |
|
|
|
'boundary.circle.lat': 111, |
|
|
|
'boundary.circle.long': 333 |
|
|
|
'boundary.circle.long': 333 |
|
|
|
}; |
|
|
|
}; |
|
|
|
var query = generate(clean); |
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.center_point; |
|
|
|
var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.center_point; |
|
|
|
var expected = { lat: clean.lat, lon: clean.lon }; |
|
|
|
var expected = { lat: clean['point.lat'], lon: clean['point.lon'] }; |
|
|
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled, expected, 'point.lat/lon overrides boundary.circle.lat/lon'); |
|
|
|
t.deepEqual(compiled, expected, 'point.lat/lon overrides boundary.circle.lat/lon'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
@ -55,7 +55,7 @@ module.exports.tests.query = function(test, common) { |
|
|
|
var sizes = [1,2,10,undefined,null]; |
|
|
|
var sizes = [1,2,10,undefined,null]; |
|
|
|
sizes.forEach( function( size ){ |
|
|
|
sizes.forEach( function( size ){ |
|
|
|
var query = generate({ |
|
|
|
var query = generate({ |
|
|
|
lat: 29.49136, lon: -82.50622, size: size |
|
|
|
'point.lat': 29.49136, 'point.lon': -82.50622, size: size |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
@ -66,7 +66,7 @@ module.exports.tests.query = function(test, common) { |
|
|
|
|
|
|
|
|
|
|
|
test('valid boundary.country reverse search', function(t) { |
|
|
|
test('valid boundary.country reverse search', function(t) { |
|
|
|
var query = generate({ |
|
|
|
var query = generate({ |
|
|
|
lat: 29.49136, lon: -82.50622, |
|
|
|
'point.lat': 29.49136, 'point.lon': -82.50622, |
|
|
|
boundary: { country: 'ABC' } |
|
|
|
boundary: { country: 'ABC' } |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|