Zend certified PHP/Magento developer

Elasticsearch results order is changing on the frontend

I’m working with magento 2.4.2 and elasticsearch 7.10.2

What I’m seeing is that even though the results in elasticsearch are ordered correctly in the backend, on the frontend are wrongly displayed. Here’s an example, the language is spanish so “lapices de colores” means “Colored Pencils”.

If I run this command:

curl 'localhost:9200/store_product_1_v118/_search?pretty&q=lapices+de+colores' 

I get the following results (for convenience I’m only showing the first hit)

 "hits" : [
  {
    "_index" : "store_product_1_v118",
    "_type" : "document",
    "_id" : "9323",
    "_score" : 13.052037,
    "_source" : {
      "store_id" : "1",
      "sku" : "PEL800049",
      "status" : 1,
      "status_value" : "Habilitado",
      "visibility" : 4,
      "tax_class_id" : 2,
      "tax_class_id_value" : "Taxable Goods",
      "name" : "lapices de colores pastel pelikan x12",
      "url_key" : "lapices-de-colores-pastel-pelikan-x12",
      "category_ids" : [
        2,
        135,
        139,
        214,
        452
      ],
      "position_category_2" : "10000",
      "name_category_2" : "RA▒~MZ ",
      "position_category_135" : "0",
      "name_category_135" : "ESCOLAR",
      "position_category_139" : "0",
      "name_category_139" : "LAPICES DE COLORES",
      "position_category_214" : "0",
      "name_category_214" : "LIBRERIA ",
      "position_category_452" : "0",
      "name_category_452" : "▒~ZTILES ESCOLARES Y KITS",
      "price_0_1" : "570.000000",
      "price_1_1" : "570.000000",
      "price_2_1" : "570.000000",
      "price_3_1" : "570.000000" 
....

But if I run the same query on the store beeing the url

https://store24.com.ar/catalogsearch/result/?q=lapices+de+colores

The results although related are not the ones given by elasticsearch.

wrong results

In the admin panel, in stores->Catalog->Catalog->”Product Listing Sort By” is set by Position.

I’m guessing that is a template issue but I don’t know how can I fix this. Here’s the sorter.phtml file used by the template:

<div class="toolbar-sorter sorter">
<label class="sorter-label" for="sorter"><?php /* @escapeNotVerified */ echo __('Sort by') ?></label>
<select id="sorter" data-role="sorter" class="sorter-options">
    <?php foreach ($block->getAvailableOrders() as $_key => $_order): ?>
        <option value="<?php /* @escapeNotVerified */ echo $_key; ?>"
            <?php if ($block->isOrderCurrent($_key)): ?>
                selected="selected"
            <?php endif; ?>
            >
            <?php echo $block->escapeHtml(__($_order)) ?>
        </option>
    <?php endforeach; ?>
</select>
<?php if ($block->getCurrentDirection() == 'desc'): ?>
    <a title="<?php /* @escapeNotVerified */ echo __('Set Ascending Direction') ?>" href="#" class="action sorter-action sort-desc" data-role="direction-switcher" data-value="asc">
        <span><?php /* @escapeNotVerified */ echo __('Set Ascending Direction') ?></span>
    </a>
<?php else: ?>
    <a title="<?php /* @escapeNotVerified */ echo __('Set Descending Direction') ?>" href="#" class="action sorter-action sort-asc" data-role="direction-switcher" data-value="desc">
        <span><?php /* @escapeNotVerified */ echo __('Set Descending Direction') ?></span>
    </a>
<?php endif; ?>

I’m not sure where or what to look for, any ideas?