3

CouchDB データベースにドキュメントを一括挿入する必要があります。ここのマニュアルに従おうとしています: http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API

これが私のスクリプトです:

~$ DB="http://localhost:5984/employees"
~$ curl -H "Content-Type:application/json" -d @employees_selfContained.json -vX POST $DB/_bulk_docs

employees_selfContained.json ファイルは巨大なファイルです = 465 MB。JSONLint を使用して検証しましたが、何も問題はありませんでした。

curl の詳細な出力は次のとおりです。

* About to connect() to 127.0.0.1 port 5984 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> POST /employees/_bulk_docs HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Type:application/json
> Content-Length: 439203931
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server
* Closing connection #0

その巨大な単一ファイルから一括挿入するにはどうすればよいですか? 可能であれば、ファイルをより小さいサイズに分割したくない..

編集:誰かが疑問に思っている場合、私はこのスキーマを変換しようとしています: http://dev.mysql.com/doc/employee/en/sakila-structure.html 次のような構造を持つ自己完結型ドキュメントデータベースに:

{
    "docs": [
        {
            "emp_no": ..,
            "birth_date": ..,
            "first_name": ..,
            "last_name" : ..,
            "gender": ..,
            "hire_date": .., 
            "titles": 
                [
                    {
                    "title": ..,
                    "from_date": .., 
                    "to_date": ..
                    },
                    {..}
                ], 
            "salaries" : 
                [
                    {
                    "salary": ..,
                    "from_date": ..,
                    "to_date": ..
                    },
                    {..}                
                ], 
            "dept_emp": 
                [ 
                    {
                    "dept_no": ..,
                    "from_date": ..,
                    "to_date":
                    },
                    {..}
                ], 
            "dept_manager": 
                [ 
                    {
                    "dept_no": ..,
                    "from_date": ..,
                    "to_date": ..
                    },
                    {..}
                ], 
            "departments":
                [
                    {
                    "dept_no": .., 
                    "dept_name": ..
                    },
                    {..}
                ]
        } ,
        .
        .
        {..}
    ]
} 
4

1 に答える 1

1

JSON をループし、10 ~ 50,000 のドキュメントのバッチに挿入します。

于 2012-06-11T13:02:14.107 に答える