# ES has lost a portion of its data by importing the json data using python3 helpers.bulk and specifying \_id

**URL:** https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719
**Category:** Elasticsearch
**Created:** [March 6, 2018, 12:31pm UTC](https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719 "2018-03-06T12:31:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![6c4518ef6a5980b3e6ef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/6c4518ef6a5980b3e6ef/32/28522_2.png) [@6c4518ef6a5980b3e6ef](https://discuss.elastic.co/u/6c4518ef6a5980b3e6ef)
#### Post date: [March 6, 2018, 12:31pm UTC](https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719/1 "2018-03-06T12:31:05Z")

</div>

**Elasticsearch version number is 2.3.3**  
**_this is my json file:_**  
{"\_source": {"bd\_id": 12345, "date\_type": "BEFORE\_SEVEN\_DAY"}, "\_score": 7.5887613, "\_id": "153380527BEFORE\_SEVEN\_DAY", "\_index": "ex\_data\_1", "\_type": "ex\_shop"}  
{"\_source": {"bd\_id": 1888, "date\_type": "BEFORE\_SEVEN\_DAY"}, "\_score": 7.5887613, "\_id": "151008189BEFORE\_SEVEN\_DAY", "\_index": "ex\_data\_1", "\_type": "ex\_shop"}  
....

**_And my code_**

```
#open josn file
    print('import data begin...')
    with open(self.re_index+'_data'+'.json', 'r',encoding='utf-8' ) as e:
        actions = deque()
        j = 0
        for i in e:
            action = {
                '_op_type': 'index',
                '_index' : json.loads(i)['_index'],
                '_type' : json.loads(i)['_type'],
                '_id' : json.loads(i)['_id'],
                '_source' : json.loads(i)['_source']
            }
            actions.append(action)
        print(len(actions))
   #helpers.bulk 
    for success, info in elasticsearch.helpers.parallel_bulk(es, actions,thread_count=50):
        if not success:
            print('Doc failed', info)
    print('import data end...\n\t total consuming time:'+str(time.time()-ip_begin)+'s')

```

**_Here is The results of the implementation:_**  
import data begin...  
60000  
import data end...  
total consuming time:19.1480000019073486s  
 ![ES__bulk](https://us1.discourse-cdn.com/elastic/original/3X/9/e/9e8df1ab6b404a37d8d0a510a0f1c5ca708e1557.jpg)

---

<div class="post-metadata">

### Author: ![6c4518ef6a5980b3e6ef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/6c4518ef6a5980b3e6ef/32/28522_2.png) [@6c4518ef6a5980b3e6ef](https://discuss.elastic.co/u/6c4518ef6a5980b3e6ef)
#### Post date: [March 6, 2018, 12:34pm UTC](https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719/2 "2018-03-06T12:34:57Z")

</div>

what's matter with code or helpers.bulk??  
I need help!!!  
@dadoonet

---

<div class="post-metadata">

### Author: ![6c4518ef6a5980b3e6ef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/6c4518ef6a5980b3e6ef/32/28522_2.png) [@6c4518ef6a5980b3e6ef](https://discuss.elastic.co/u/6c4518ef6a5980b3e6ef)
#### Post date: [March 8, 2018, 6:56am UTC](https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719/3 "2018-03-08T06:56:29Z")

</div>

Are people asleep????????????

---

<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: [April 16, 2018, 8:31am UTC](https://discuss.elastic.co/t/es-has-lost-a-portion-of-its-data-by-importing-the-json-data-using-python3-helpers-bulk-and-specifying-id/122719/5 "2018-04-16T08:31:16Z")

</div>

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