Support Forums - Classified Ads Script Osclass
General osclass questions => Feature request => Topic started by: Alej on March 20, 2025, 04:22:51 PM
-
Hello, when I search for "Remera Tommy Hilfiger" on my website (T-shirt in Spanish), instead of displaying relevant results first, I get the most recent ones. In the image, you can see a Levi's T-shirt. You should improve the search so that relevant results appear first. I'm using the search settings:
Pattern filter method: Enhanced full-text search (with NLP)
-
Enable query debug log and check if query does not have orderby dt_pub_date desc.
There was little uodate regards to this, where when you search by pattern, sorting works differently
-
I did, and found the following query with that string:
SELECT df7a_t_item.*, df7a_t_item.s_contact_name as s_user_name
FROM (df7a_t_item)
LEFT JOIN df7a_t_item_description as d ON d.fk_i_item_id = df7a_t_item.pk_i_id
LEFT OUTER JOIN df7a_t_item_epsilon ON df7a_t_item.pk_i_id = df7a_t_item_epsilon.fk_i_item_id
WHERE MATCH(d.s_title, d.s_description) AGAINST('remera tommy hilfiger' IN NATURAL LANGUAGE MODE)
AND (d.fk_c_locale_code LIKE 'es_ES')
AND df7a_t_item.b_enabled = 1 AND df7a_t_item.b_active = 1 AND df7a_t_item.b_spam = 0 AND (df7a_t_item.b_premium = 1 || df7a_t_item.dt_expiration >= '2025-03-22 11:37:41')
GROUP BY df7a_t_item.pk_i_id
ORDER BY dt_pub_date desc
LIMIT 0, 10
-
ORDER BY dt_pub_date desc
Means results are not sorted by relevance. It might lead to confusion to be honest. If you have sort by pub date and once you enter pattern, it's not anymore...
-
Ok, it should be updated so that it doesn't have this behavior.
-
Currently we does not plan to add "sort by releavnce" but maybe it gets into in osclass 8.4
-
Could you tell me what I should modify to sort by publication date, but once the pattern is entered?
-
you need to play with controller/search.php, find "orderby" and test different scenarios.
-
i found this code:
// FILTERING PATTERN
if($p_sPattern != '') {
$this->mSearch->addPattern($p_sPattern);
$osc_request['sPattern'] = $p_sPattern;
} else {
// hardcoded - if there isn't a search pattern, order by dt_pub_date desc
if($p_sOrder == 'relevance') {
$p_sOrder = 'dt_pub_date';
foreach($allowedTypesForSorting as $k => $v) {
if($p_iOrderType=='desc') {
$orderType = $k;
break;
}
}
$p_iOrderType = $orderType;
}
}
It sorts the results when there's no search term, showing the most recent first. But why does it sort them by most recent if there are search terms?