# Elastic search Data fetch

**URL:** <https://discuss.elastic.co/t/elastic-search-data-fetch/279231>\
**Category:** Elasticsearch\
**Created:** [July 21, 2021, 7:19am UTC](https://discuss.elastic.co/t/elastic-search-data-fetch/279231 "2021-07-21T07:19:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamendra\_Sunthwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamendra_sunthwal/32/51288_2.png) [@Hamendra\_Sunthwal](https://discuss.elastic.co/u/Hamendra_Sunthwal)\
**Post date:** [July 21, 2021, 7:19am UTC](https://discuss.elastic.co/t/elastic-search-data-fetch/279231/1 "2021-07-21T07:19:07Z")

</div>

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);
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 18, 2021, 7:19am UTC](https://discuss.elastic.co/t/elastic-search-data-fetch/279231/2 "2021-08-18T07:19:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
