Skip to content

Commit 39f8564

Browse files
authored
Merge branch 'main' into feature/support-wheres
2 parents aefd744 + a9b4917 commit 39f8564

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## v1.4.1 - 2024-11-14
6+
7+
### What's Changed
8+
9+
* Fix whereStatus error by @ryanmitchell in https://github.com/statamic-rad-pack/typesense/pull/9
10+
11+
**Full Changelog**: https://github.com/statamic-rad-pack/typesense/compare/v1.4.0...v1.4.1
12+
513
## v1.4.0 - 2024-11-12
614

715
### What's Changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ Any additional settings you want to define per index can be included in the `sta
102102
*/
103103
'sort_by' => '_text_match(buckets: 10):desc,weighted_score:desc',
104104
],
105+
106+
/*
107+
Set this to true to maintain the sort score order that Typesense returns
108+
*/
109+
'maintain_rankings' => false,
105110
],
106111
],
107112
```

src/Typesense/Index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ public function searchUsingApi($query, array $options = []): array
114114

115115
$searchResults = $this->getOrCreateIndex()->documents->search($options);
116116

117+
$total = count($searchResults['hits']);
118+
117119
return [
118120
'raw' => $searchResults,
119121
'results' => collect($searchResults['hits'] ?? [])
120-
->map(function ($result, $i) {
122+
->map(function ($result, $i) use ($total) {
121123
$result['document']['reference'] = $result['document']['id'];
122-
$result['document']['search_score'] = (int) ($result['text_match'] ?? 0);
124+
$result['document']['search_score'] = Arr::get($this->config, 'settings.maintain_ranking', false) ? ($total - $i) : (int) ($result['text_match'] ?? 0);
123125

124126
return $result['document'];
125127
}),

0 commit comments

Comments
 (0)