@ -110,6 +110,7 @@ function createExpectedQuery(){
'track_scores' : true
} ;
}
module . exports . tests . query = function ( test , common ) {
test ( 'valid query' , function ( t ) {
var query = generate ( {
@ -150,31 +151,8 @@ module.exports.tests.query = function(test, common) {
layers : [ 'test' ]
} ) ;
var expected = {
'query' : {
'filtered' : {
'query' : {
'bool' : {
'must' : [ {
'match' : {
'name.default' : 'test'
}
}
]
}
} ,
'filter' : {
'bool' : {
'must' : [ ]
}
}
}
} ,
'size' : 10 ,
'sort' : sort ,
'track_scores' : true
} ;
var expected = createExpectedQuery ( ) ;
expected . query . filtered . filter . bool . must = [ ] ;
t . deepEqual ( query , expected , 'valid search query' ) ;
t . end ( ) ;
} ) ;
@ -186,23 +164,8 @@ module.exports.tests.query = function(test, common) {
layers : [ 'test' ]
} ) ;
var expected = {
'query' : {
'filtered' : {
'query' : {
'bool' : {
'must' : [ {
'match' : {
'name.default' : 'test'
}
}
]
}
} ,
'filter' : {
'bool' : {
'must' : [
{
var expected = createExpectedQuery ( ) ;
expected . query . filtered . filter . bool . must = [ {
'geo_distance' : {
'distance' : '50km' ,
'distance_type' : 'plane' ,
@ -213,13 +176,9 @@ module.exports.tests.query = function(test, common) {
'lon' : '-82.51'
}
}
}
]
}
}
}
} ,
'sort' : [
} ] ;
expected . sort . shift ( ) ;
expected . sort . unshift (
'_score' ,
{
'_geo_distance' : {
@ -231,10 +190,7 @@ module.exports.tests.query = function(test, common) {
'unit' : 'km'
}
}
] . concat ( sort . slice ( 1 ) ) ,
'size' : 10 ,
'track_scores' : true
} ;
) ;
t . deepEqual ( query , expected , 'valid search query' ) ;
t . end ( ) ;