From 6c8e488c7c523f916b04d7d7eba12050484d2119 Mon Sep 17 00:00:00 2001 From: WilliamPeralta Date: Thu, 24 May 2018 12:28:31 +0200 Subject: [PATCH] support fields exclude in result --- src/ElasticquentTrait.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 +}