按类别产品循环中的位置排序,在magento 2中使用微笑弹性搜索

I am creating a product loop on the homepage of our site. The site has smile elastic search running. I have set up the manual sort for products in the category admin and can loop thru the products, but I am not able to sort by position.

<?php foreach ($category as $categoryId): ?>
<?php 

$category = $categoryFactory->create()->load($categoryId);
$categoryProducts = $category->getProductCollection()
                        ->addAttributeToSort('position','ASC')
                        ->addAttributeToSelect('*');

?>

<?php foreach ($categoryProducts as $product): ?>

    // do something with the products

<?php endforeach ?>