diff --git a/src/ElasticquentTrait.php b/src/ElasticquentTrait.php index 539cb96..8e2d56c 100644 --- a/src/ElasticquentTrait.php +++ b/src/ElasticquentTrait.php @@ -248,7 +248,11 @@ public static function searchByQuery($query = null, $aggregations = null, $sourc $params = $instance->getBasicEsParams(true, true, true, $limit, $offset); if ($sourceFields) { - $params['body']['_source']['include'] = $sourceFields; + if( isset($sourceFields['include']) || isset($sourceFields['exclude']) ) { + $params['body']['_source'] = $sourceFields; + }else{ + $params['body']['_source']['include'] = $sourceFields; + } } if ($query) { @@ -558,4 +562,4 @@ public function newFromHitBuilder($hit = array()) return $instance; } -} \ No newline at end of file +}