From 8b5f990feb6841f5e17977e3722bdbf681a1e9f9 Mon Sep 17 00:00:00 2001 From: WilliamPeralta Date: Thu, 24 May 2018 12:35:13 +0200 Subject: [PATCH] support fields exclusion in results --- src/ElasticquentTrait.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)) {