# bulkで20M以上のデータを登録したい

**URL:** <https://discuss.elastic.co/t/bulk-20m/112189>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [December 18, 2017, 9:24am UTC](https://discuss.elastic.co/t/bulk-20m/112189 "2017-12-18T09:24:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thagie1i2321](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@thagie1i2321](https://discuss.elastic.co/u/thagie1i2321)\
**Post date:** [December 18, 2017, 9:24am UTC](https://discuss.elastic.co/t/bulk-20m/112189/1 "2017-12-18T09:24:42Z")

</div>

お世話になります。  
フォーラムへは初投稿です。

現在 bulkAPIを利用しての大量データ登録のスクリプトを作成しています。  
公式では5〜15Mが推奨とされていますがどうしても20M以上の登録が不可欠となっています。

試してみたこと  
・refresh\_interval -1  
・number\_of\_replicas 0  
・indices.store.throttle.max\_bytes\_per\_sec "100mb"  
・indices.store.throttle.type "none"  
・http.max\_content\_lengthはデフォルト(100mb)  
を試しましたがダメでした。  
結果としては  
curlで実行して  
curl: (52) Empty reply from server  
が返却されてしまいます。

何か設定が足りないのでしょうか。。。

どうぞお力添えをよろしくお願いいたします。

---

<div class="post-metadata">

**Author:** ![tsgkdt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsgkdt/32/39151_2.png) [@tsgkdt](https://discuss.elastic.co/u/tsgkdt)\
**Post date:** [December 19, 2017, 1:19am UTC](https://discuss.elastic.co/t/bulk-20m/112189/2 "2017-12-19T01:19:20Z")

</div>

こちらでは、およそ50mb程度になるjsonをbulk apiを利用して登録してみましたが、正常に登録できました。  
curlで試されているとのことですが、Elasticsearchサーバ側で何らかのログが出力されてませんか？

参考までにこちらで正常に登録できた環境とテストデータを書いておきます。

## 試した環境

Elasticsearch 6.0.1

## Indexの設定

```auto
PUT 20megaover
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  }
}

```

## テストスクリプト

```auto
from elasticsearch import Elasticsearch, helpers
es = Elasticsearch('http://xxx.xxx.xxx.xxx:9200')

def create_doc():
    doc = {
        'number1': random.randint(1, 100),
        'number2': random.randint(1, 5000),
        'number3': random.randint(1, 10000),
        'text1': 'asdfasdfasdfasdfasdf',
        'text2': 'あいうえおかきくけこさしすせそ',
        'text3': '隣の客はよく柿食う客だ',
        'text4': 'asdfasdfasdfasdfasdf',
        'text5': 'あいうえおかきくけこさしすせそ',
        'text6': '隣の客はよく柿食う客だ',
        'text7': 'asdfasdfasdfasdfasdf',
        'text8': 'あいうえおかきくけこさしすせそ',
        'text9': '隣の客はよく柿食う客だ',
        'text10': 'asdfasdfasdfasdfasdf',
        'text11': 'あいうえおかきくけこさしすせそ',
        'text12': '隣の客はよく柿食う客だ',
        'text13': 'asdfasdfasdfasdfasdf',
        'text14': 'あいうえおかきくけこさしすせそ',
        'text15': '隣の客はよく柿食う客だ',
        'text16': 'asdfasdfasdfasdfasdf',
        'text17': 'あいうえおかきくけこさしすせそ',
        'text18': '隣の客はよく柿食う客だ',
        'text19': 'asdfasdfasdfasdfasdf',
        'text20': 'あいうえおかきくけこさしすせそ',
        'text21': '隣の客はよく柿食う客だ',
    }

    return doc

actions = []

# 50万レコード だいたい50mb弱になるをbulkで送信
for row in range(500000):
    doc = create_doc()
    type = 'test'
    actions.append({'_index': '20megaover', '_type': 'test', '_id': row, '_source': doc})
helpers.bulk(es, actions)

```

---

<div class="post-metadata">

**Author:** ![thagie1i2321](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@thagie1i2321](https://discuss.elastic.co/u/thagie1i2321)\
**Post date:** [December 19, 2017, 9:24am UTC](https://discuss.elastic.co/t/bulk-20m/112189/3 "2017-12-19T09:24:35Z")

</div>

ご返信ありがとうございます。  
ログは何も出力されておりませんでした。。

１つのオブジェクトが結構大きかったりするのでその辺りでも調べてみようと思っています。

テストありがとうございます。

---

<div class="post-metadata">

**Author:** ![tsgkdt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsgkdt/32/39151_2.png) [@tsgkdt](https://discuss.elastic.co/u/tsgkdt)\
**Post date:** [December 20, 2017, 12:56am UTC](https://discuss.elastic.co/t/bulk-20m/112189/4 "2017-12-20T00:56:20Z")

</div>

ここのフォーラムでも「curl Empty reply from server」などで検索すると、何件かヒットします。  
また、OutOfMemoryの発生でも同様のエラーになったとGoogleで検索しても出てきます。  
何かヒントになることがあるかもしれません。

あと、試された設定値については書かれているのですが、  
利用されているElasticsearchのバージョンや、Heapの設定などの環境情報がないようです。  
回答を得やすくするためには、こうした環境情報や、具体的な手順やデータがあれば、なお良いと思います。

---

<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:** [January 17, 2018, 12:57am UTC](https://discuss.elastic.co/t/bulk-20m/112189/5 "2018-01-17T00:57:03Z")

</div>

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