*

Alej

  • ***
  • 50 posts
search results issue
« 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)

*

MB Themes

Re: search results issue
« Reply #1 on: March 22, 2025, 08:11:35 AM »
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
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • ***
  • 50 posts
Re: search results issue
« Reply #2 on: March 22, 2025, 03:40:10 PM »
I did, and found the following query with that string:
Code: [Select]
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

*

MB Themes

Re: search results issue
« Reply #3 on: March 26, 2025, 02:39:20 PM »
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...
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • ***
  • 50 posts
Re: search results issue
« Reply #4 on: March 26, 2025, 03:26:03 PM »
Ok, it should be updated so that it doesn't have this behavior.

*

MB Themes

Re: search results issue
« Reply #5 on: March 26, 2025, 03:46:05 PM »
Currently we does not plan to add "sort by releavnce" but maybe it gets into in osclass 8.4
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • ***
  • 50 posts
Re: search results issue
« Reply #6 on: March 26, 2025, 03:55:54 PM »
Could you tell me what I should modify to sort by publication date, but once the pattern is entered?

*

MB Themes

Re: search results issue
« Reply #7 on: March 26, 2025, 03:57:45 PM »
you need to play with controller/search.php, find "orderby" and test different scenarios.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Alej

  • ***
  • 50 posts
Re: search results issue
« Reply #8 on: March 26, 2025, 04:12:54 PM »
i found this code:
Code: [Select]
// 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?