diff --git a/src/ElasticquentTrait.php b/src/ElasticquentTrait.php index de56e32..feb85e0 100644 --- a/src/ElasticquentTrait.php +++ b/src/ElasticquentTrait.php @@ -228,7 +228,11 @@ public static function searchByQuery($query = null, $aggregations = null, $sourc $params = $instance->getBasicEsParams(true, $limit, $offset); if (!empty($sourceFields)) { - $params['body']['_source']['include'] = $sourceFields; + if( isset($sourceFields['include']) || isset($sourceFields['exclude']) ) { + $params['body']['_source'] = $sourceFields; + }else{ + $params['body']['_source']['include'] = $sourceFields; + } } if (!empty($query)) {