@@ -541,26 +541,39 @@ module.exports = function Mongoosastic(schema, options) {
541541
542542 var queryHookFunc = function ( result ) {
543543 if ( ( typeof this . _conditions == 'object' ) && ( Object . getOwnPropertyNames ( this . _conditions ) . length > 0 ) ) {
544+ //console.log('this:', this);
544545 var theModel = this . model ;
545546 var origCondition = this . _conditions ;
546547 var finalCondition = null ;
548+ //console.log('origCondition:', origCondition);
549+ //console.log('identifyingPaths:', identifyingPaths);
547550 finalCondition = _ . foldl ( identifyingPaths , function ( final , path ) {
548551 var theVal = _ . get ( origCondition , path ) ;
549552 if ( theVal ) {
550553 final [ path ] = theVal ;
554+ } else {
555+ if ( origCondition . $or [ 0 ] ) {
556+ theVal = origCondition . $or [ 0 ] [ path ] ;
557+ if ( theVal ) {
558+ final [ path ] = theVal ;
559+ }
560+ }
551561 }
552562 return final
553563 } , { } ) ;
554564 if ( _ . isEmpty ( finalCondition ) ) {
555565 finalCondition = origCondition ;
556566 }
567+ //console.log('finalCondition:', finalCondition);
557568 this . model . find ( finalCondition ) . limit ( 50 ) . exec ( function ( err , results ) {
569+ //console.log("results:", results, "result:", result);
558570 if ( err ) {
559571 return
560572 }
561573 if ( results && results . length > 0 ) {
562574 results . forEach (
563575 function ( record ) {
576+ //console.log('record is', record);
564577 record . index ( ) ;
565578 }
566579 )
0 commit comments