# Rate limit exceeded

**URL:** <https://discuss.elastic.co/t/rate-limit-exceeded/203867>\
**Category:** Elastic Search\
**Tags:** elastic-site-search\
**Created:** [October 16, 2019, 2:58pm UTC](https://discuss.elastic.co/t/rate-limit-exceeded/203867 "2019-10-16T14:58:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Simard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patrick_simard/32/56027_2.png) [@Patrick\_Simard](https://discuss.elastic.co/u/Patrick_Simard)\
**Post date:** [October 16, 2019, 2:58pm UTC](https://discuss.elastic.co/t/rate-limit-exceeded/203867/1 "2019-10-16T14:58:20Z")

</div>

I currently have a demo account. I am trying to make a POC using SwifType for my employer. We have a very big database that is indexec every 1h and creates a JSON file. I thought the integration with Elastic would be very easy considering it's only a mater of sending the string when it's generated. I used PHP Curl and got a connection to the API. The code sends out part of the data and then freaks out with a "Rate limit exceeded" error.

How can I manage around that error and get the full JSON indexed?

My code looks like this at the moment:

```
// SENDING DATA TO ELASTIC SEARCH
$arr = array_change_key_case($arr, CASE_LOWER); // Keys to lower case
$arrlist = array_chunk($arr,100); // Split to chunks of 100
foreach($arrlist as $key=>$arr){
    $json = json_encode($arr); // Making the JSON string from the array
    $ch = curl_init('https://host- ***.api.swiftype.com/api/as/v1/engines/*** /documents');                                                                      
    curl_setopt($ch, CURLOPT_POST, 1);                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);                                                                  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);      
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                                                                
    $headers = array();
    $headers[] = 'Content-Type: application/json';
    $headers[] = 'Authorization: Bearer private-***';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);
    
    echo $result."<hr>";
}

```

Also, considering this code is going to be indexed every hour, if I am sending the same data over and over, will it UPDATE the previous one or will it duplicate it? If so, how can I manage that?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [October 22, 2019, 8:02pm UTC](https://discuss.elastic.co/t/rate-limit-exceeded/203867/2 "2019-10-22T20:02:44Z")

</div>

Hey @Patrick_Simard,

Sorry that you are having trouble getting your content indexed. Here is a knowledge base article on Rate Limiting: [https://swiftype.com/documentation/site-search/rate\_limiting](https://swiftype.com/documentation/site-search/rate_limiting).

Also, check out the documentation on `documents`, you can use the `create_or_update` endpoint: [https://swiftype.com/documentation/site-search/indexing#add-document](https://swiftype.com/documentation/site-search/indexing#add-document).

Jason

---

<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:** [November 19, 2019, 8:02pm UTC](https://discuss.elastic.co/t/rate-limit-exceeded/203867/3 "2019-11-19T20:02:48Z")

</div>

Closed on November 19, 2019, 8:02pm UTC

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