Skip to content

Commit

Permalink
add true random search when no parameters (excepted pager )are given …
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK committed Feb 9, 2024
1 parent db05366 commit 5526dd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- remove caches on both Search & Autocomplete endpoints (Elasticsearch)

### Added
- add true random search when no parameters (excepted pager )are given on search - Games-of-Switzerland/swissgamesgarden#127

## [0.6.0] - 2024-02-09
### Changed
- move Linters php-deprecation-detector, php-cs-fixer & psalm into own Tools/ComposerJson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ public function get(Request $request): CacheableJsonResponse {
$es_query['body']['aggregations']['aggs_all']['aggs']['all_filtered_release_years_histogram']['filter']['bool']['should'][] = $this->addStatesFilter($states);
}

// When no parameters (excepted pager) have been submitted,
// then the order must be random.
// This is intended to be used on Homepage only.
if ($resource_validator->getRaw() === ['page' => '0']) {
$es_query['body']['query'] = [
'function_score' => [
'query' => $es_query['body']['query'],
'random_score' => (object) [],
],
];
}

try {
$results = $index->search($es_query);
$this->response->setData($results);
Expand Down

0 comments on commit 5526dd6

Please sign in to comment.