diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-20 16:25:58 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-20 16:25:58 +0100 |
| commit | 2d9e56ca5f29c9dc1e295f534d1be18ed11df9a7 (patch) | |
| tree | 785eda0313da2d01981b0ede82440d845904b00e /includes | |
| parent | b34037865426033d3684fc58b7f65a7d1863a29e (diff) | |
| download | search-2d9e56ca5f29c9dc1e295f534d1be18ed11df9a7.tar.gz search-2d9e56ca5f29c9dc1e295f534d1be18ed11df9a7.tar.bz2 search-2d9e56ca5f29c9dc1e295f534d1be18ed11df9a7.zip | |
Fix And Terms Together search for Firebird and PHP namespaces
- ORDER BY relevancy/hits by name instead of position 9/5; position 9
resolved to lc.data (BLOB) in find_with_and due to extra hash_key
column, causing Firebird to error on BLOB sort
- Qualify i_count with table alias to avoid ambiguity
- Replace string callback 'search_relevance_sort' with closure; string
callbacks resolve in global namespace but function is in Bitweaver\Search
- Remove now-redundant standalone search_relevance_sort function
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/classes/SearchLib.php | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/includes/classes/SearchLib.php b/includes/classes/SearchLib.php index ae0c403..821443d 100755 --- a/includes/classes/SearchLib.php +++ b/includes/classes/SearchLib.php @@ -243,8 +243,8 @@ class SearchLib extends BitBase { LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_content_hits` lch ON (lc.`content_id` = lch.`content_id`) $joinSql INNER JOIN `".BIT_DB_PREFIX."search_index` si ON (si.`content_id`=lc.`content_id` AND si.`searchword` = ? ) - WHERE `i_count` > 0 $whereSql - ORDER BY 9 DESC, 5 DESC + WHERE si.`i_count` > 0 $whereSql + ORDER BY relevancy DESC, hits DESC "; $bindVars[0] = $word; $result = $this->mDb->getAssoc( $query, $bindVars ); @@ -260,7 +260,10 @@ class SearchLib extends BitBase { $pParamHash['cant'] = count($ret); /* Sort it */ - uasort($ret, 'search_relevance_sort'); + uasort($ret, function($a, $b) { + $rel = $b['relevancy'] - $a['relevancy']; + return $rel == 0 ? $b['hits'] - $a['hits'] : $rel; + }); /* slice it */ $ret = array_slice($ret, $pParamHash['offset'], $pParamHash['offset'] + $pParamHash['max_records']); @@ -332,12 +335,3 @@ class SearchLib extends BitBase { } # class SearchLib -if (!defined('search_relevance_sort')) { - function search_relevance_sort($a, $b) { - $rel = $b['relevancy'] - $a['relevancy']; - if ($rel == 0) { - $rel = $b['hits'] - $a['hits']; - } - return $rel; - } -}
\ No newline at end of file |
