reindex – Magento 2 How do I use Elasticsearch for a custom indexer? Custom sorting stops working after Elasticsearch has been activated

I'm a Magento newbie and I'm trying to implement a custom sort on the product list page:
https://magento.stackexchange.com/a/230983/84727

In addition to the solution, I've created a custom indexer with the assumption that the elastic search would track the index through Magento, but if you select the option, this error appears in the debug log:

{"error":{"root_cause":({"type":"query_shard_exception","reason":"No mapping found for (sale_count) in order to sort on","index_uuid":"bWC-SqwXSpijk9cpKLT7PA","index":"magento2_product_1_v4"}),"type":"search_phase_execution_exception","reason":"all shards failed" ,"phase":"query","grouped":true,"failed_shards":({"shard":0,"index":"magento2_product_1_v4","node":"YrKI9XCaSwSEAB5KNGBSvw","reason":{"type":"query_shard_exception","reason":"No mapping found for (sale_count) in order to sort on","index_uuid":"bWC-SqwXSpijk9cpKLT7PA","index":"magento2_product_1_v4"}})},"status":400} {"exception":"(object) (Elasticsearch\Common\Exceptions\BadRequest400Exception(code: 400): {"error":{"root_cause":({"type": "query_shard_exception","reason":"No mapping found for (sale_count) in order to sort on","index_uuid":"bWC-SqwXSpijk9cpKLT7PA","index":"m agento2_product_1_v4"}),"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":({"shard":0,"index":"magento2_product_1_v4","node":"YrKI9XCaSwSEAB5KNGBSvw","reason":{"type":"query_shard_exception","reason":"No mapping found for (sale_count) in order to sort on","index_uuid":"bWC-SqwXSpijk9cpKLT7PA","index":"magento2_product_1_v4"}})},"status":400} at /var/www/html/mg2/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:636)"}  

By this I understand that there is no mapping called "sale_count", but it's hard to understand how to transfer it to elasticsearch.

Here's my indexer class function, which runs fine and creates the appropriate data in my spreadsheet.

/**
 * @param array $ids
 */
private function reindex($ids = ())
{
    $this->logger->info('Trying to run indexer');
    $select = $this->connection->select()
        ->from('sales_order_item', (
            'product_id' => 'product_id',
            'sale_count' => 'SUM(qty_ordered)'
        ))
        ->group('product_id');
    $this->connection->query(
        $this->connection->insertFromSelect($select, 'catalog_product_sale_count', (
            'product_id',
            'sale_count'
        ), MagentoFrameworkDBAdapterAdapterInterface::REPLACE)
    );
}

And for the sort handler, I use a BeforePlugin like this:

class Bestsellers 
{
/**
 * Bestsellers sorting attribute
 */
const BESTSELLERS_SORT_BY = 'sale_count';

/**
 * @param Config $subject
 * @param $result
 * @return array
 */
public function afterGetAttributeUsedForSortByArray(Config $subject, $result)
{
    return array_merge($result, (self::BESTSELLERS_SORT_BY => __('Best Sellers')));
}

/**
 * @param Toolbar $subject
 * @param Collection $collection
 */
public function beforeSetCollection(Toolbar $subject, Collection $collection)
{
    if ($subject->getCurrentOrder() == self::BESTSELLERS_SORT_BY) {
        $collection->getSelect()->joinLeft(
            'catalog_product_sale_count',
            'e.entity_id = catalog_product_sale_count.product_id',
            ('sale_count')
        )
            ->group('e.entity_id')
            ->order('catalog_product_sale_count.sale_count ' . $subject->getCurrentDirection());
    }
}
}

Need help to solve this problem?

thank you in advance