File tree 2 files changed +28
-4
lines changed
2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -290,11 +290,14 @@ AWSES.prototype.search = function(options, callback) {
290
290
var qs = { } ;
291
291
if ( options . scroll ) qs . scroll = options . scroll ;
292
292
if ( options . searchType ) qs . search_type = options . searchType ;
293
- if ( options . defaultOperator ) qs . default_operator = options . defaultOperator ;
294
293
if ( options . size ) qs . size = options . size ;
295
294
if ( options . from ) qs . from = options . from ;
296
295
if ( options . sort ) qs . sort = options . sort ;
297
296
297
+ if ( is . existy ( options . defaultOperator ) && is . existy ( options . body )
298
+ && is . existy ( options . body . query ) && is . existy ( options . body . query . query_string ) )
299
+ options . body . query . query_string . default_operator = options . defaultOperator ;
300
+
298
301
var path = '/' + options . index + '/' + options . type + '/_search' ;
299
302
path += '/?' + querystring . stringify ( qs ) ;
300
303
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ describe('aws-es', function() {
35
35
type : TYPE ,
36
36
id : '1' ,
37
37
body : {
38
- title : 'first title' ,
38
+ title : 'first post title' ,
39
39
shares : 2
40
40
}
41
41
} , function ( err , data ) {
@@ -398,7 +398,7 @@ describe('aws-es', function() {
398
398
type : TYPE ,
399
399
id : '2' ,
400
400
body : {
401
- title : 'second title' ,
401
+ title : 'second post title' ,
402
402
shares : 10
403
403
}
404
404
} , function ( err , data ) {
@@ -603,7 +603,7 @@ describe('aws-es', function() {
603
603
604
604
var ops = [ ] ;
605
605
ops . push ( { update : { _id : '1' } } ) ;
606
- ops . push ( { doc : { title : 'brand new' } } ) ;
606
+ ops . push ( { doc : { title : 'brand new title ' } } ) ;
607
607
608
608
elasticsearch . bulk ( {
609
609
index : INDEX ,
@@ -923,6 +923,27 @@ describe('aws-es', function() {
923
923
done ( ) ;
924
924
} ) ;
925
925
} ) ;
926
+
927
+ it ( 'should succeed with defaultOperator AND' , function ( done ) {
928
+ this . timeout ( 20000 ) ;
929
+
930
+ elasticsearch . search ( {
931
+ index : INDEX ,
932
+ type : TYPE ,
933
+ body : {
934
+ query : {
935
+ query_string : {
936
+ query : 'second title'
937
+ }
938
+ }
939
+ } ,
940
+ defaultOperator : 'AND'
941
+ } , function ( err , data ) {
942
+ expect ( err ) . to . be . null ;
943
+ expect ( data . hits . hits . length ) . to . be . equal ( 1 ) ;
944
+ done ( ) ;
945
+ } ) ;
946
+ } ) ;
926
947
} ) ;
927
948
928
949
describe ( 'scroll' , function ( ) {
You can’t perform that action at this time.
0 commit comments