magento2 – Magento 2 : Elastic search Data fetch

I am using below script to fetch data from Elastic search,
I want to know how the data is being fetched from Magento to ES.

This script get me product details in Output, but for some product the data is incorrect
i need to check for it.
I am not sure from where product is being pass to ES, so please advise me or let me know how it works actually.

require_once '../mageless/api_bootstrap.php';
    $app = new LightApi();
    $app->setOutput(());
    
    $currentEnv = 'prod';
    $currentSite = 11;
    $pid = preg_replace('(^0-9,)', '', $_GET('pid'));
    $productIds = array_diff(array_map('intval', explode(',', $pid)), (0))
    $index = 'magento2_product_11_v14';
    $host = 'localhost:9200';
    $query = (
        'query' => (
            'ids' => (
              'values' => $productIds
            )
        )
    );
    
    $ch = curl_init('http://' . $host . '/' . $index . '/_search?pretty');
    echo 'http://' . $host . '/' . $index . '/_search?pretty'; exit;
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt($ch, CURLOPT_POST,           1 );
    curl_setopt($ch, CURLOPT_POSTFIELDS,     json_encode($query));
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    $result = curl_exec($ch);
    $result = json_decode($result, TRUE);