Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Search Settings (Edit the body of the request) #363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ElasticEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public function buildSearchQueryPayloadCollection(Builder $builder, array $optio
$payload->setIfNotEmpty($clauseKey, $clauseValue);
}

$settings = $builder->model->getSearchSettings();
foreach ($settings as $setting => $value) {
$settingKey = 'body.'.$setting;
$payload->setIfNotEmpty($settingKey, $value);
}

return $payload->get();
});
}
Expand Down
11 changes: 11 additions & 0 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ public function getSearchRules()
$this->searchRules : [SearchRule::class];
}

/**
* Get the search rules.
*
* @return array
*/
public function getSearchSettings()
{
return isset($this->searchSettings) && count($this->searchSettings) > 0 ?
$this->searchSettings : [];
}

/**
* Execute the search.
*
Expand Down