1
0
Fork 0
arangodb/Doxygen/doc/HttpImport.html

65 lines
5.6 KiB
HTML

<html><head><title>ArangoDB Manual</title> <style media="screen" type="text/css" style="display:none">body{background-color:white;font:13px Helvetica,arial,freesans,clean,sans-serif;line-height:1.4;color:#333;}#access{font-size:16px;margin-left:12px;display:block;margin-left:10px;margin-right:10px;background-color:#F3F1EE!important;}#access a{border-right:1px solid #DBDEDF;color:#A49F96;display:block;line-height:38px;padding:0 10px;text-decoration:none;}#navigation ul{text-transform:uppercase;list-style:none;margin:0;}#navigation li{float:left;position:relative;}#container{width:920px;margin:0 auto;}a{color:#4183C4;text-decoration:none;}.contents h2{font-size:24px;border-bottom:1px solid #CCC;color:black;}.contents h1{font-size:33px;border-bottom:1px solid #CCC;color:black;}.clearfix:after{content:".";display:block;clear:both;font-size:0;height:0;visibility:hidden;}/**/ *:first-child+html .clearfix{min-height:0;}/**/ * html .clearfix{height:1%;}</style></head><body><div id="container"><img src="images/logo_arangodb.png" width="397" height="67" alt="ArangoDB"><div id="access" role="navigation"><div id="navigation"><ul id="menu-ahome" class="menu"><li><a href="Home.html">Table of contents</a></li> <li><a href="http://www.arangodb.org">ArangoDB homepage</a></li></ul></div><div class="clearfix"></div></div><div>
<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div class="header">
<div class="headertitle">
<h1>HTTP Interface for bulk imports </h1> </div>
</div>
<div class="contents">
<div class="textblock"><p>ArangoDB provides an HTTP interface to import multiple documents at once into a collection. This is known as a bulk import.</p>
<hr/>
<ul>
<li>
<a class="el" href="HttpImport.html">HTTP Interface for bulk imports</a> <ul>
<li>
<a class="el" href="HttpImport.html#HttpImportSelfContained">Importing self-contained documents</a> </li>
<li>
<a class="el" href="HttpImport.html#HttpImportHeaderData">Importing headers and values</a> </li>
</ul>
</li>
</ul>
<hr/>
The data uploaded must be provided in JSON format. There are two mechanisms to import the data:</p>
<ul>
<li>self-contained documents: in this case, each document contains all attribute names and values. Attribute names may be completely different among the documents uploaded</li>
<li>attribute names plus document data: in this case, the first document must be a JSON list containing the attribute names of the documents that follow. The following documents must be lists containing only the document data. Data will be mapped to the attribute names by attribute positions.</li>
</ul>
<p>The endpoint address is <code>/_api/import</code> for both input mechanisms. Data must be sent to this URL using an HTTP POST request. The data to import must be contained in the body of the POST request.</p>
<p>The <code>collection</code> URL parameter must be used to specify the target collection for the import. The optional URL parameter <code>createCollection</code> can be used to create a non-existing collection during the import. If not used, importing data into a non-existing collection will produce an error.</p>
<h2><a class="anchor" id="HttpImportSelfContained"></a>
Importing self-contained documents</h2>
<p>This import method allows uploading self-contained JSON documents. The documents must be uploaded in the body of the HTTP POST request. Each line of the body will be interpreted as one stand-alone document. Empty lines in the body are allowed and will be skipped.</p>
<p>To use this method, the <code>type</code> URL parameter should be set to <code>documents</code>.</p>
<p><b>Examples</b><br/>
</p>
<div class="fragment"><pre class="fragment">curl --data-binary @- -X POST --dump - "http://localhost:8529/_api/import?type=documents&amp;collection=test&amp;createCollection=true"
{ "name" : "test", "gender" : "male", "age" : 39 }
{ "type" : "bird", "name" : "robin" }
HTTP/1.1 201 Created
server: triagens GmbH High-Performance HTTP Server
connection: Keep-Alive
content-type: application/json; charset=utf-8
{"error":false,"created":2,"errors":0}
</pre></div><p>The server will respond with an HTTP 201 if everything went well. The number of documents imported will be returned in the <code>created</code> attribute of the response. If any documents were skipped or incorrectly formatted, this will be returned in the <code>errors</code> attribute.</p>
<h2><a class="anchor" id="HttpImportHeaderData"></a>
Importing headers and values</h2>
<p>When using this type of import, the attribute names of the documents to be imported are specified separate from the actual document value data. The first line of the HTTP POST request body must be a JSON list containing the attribute names for the documents that follow. The following lines are interpreted as the document data. Each document must be a JSON list of values. No attribute names are needed or allowed in this data section.</p>
<p><b>Examples</b><br/>
</p>
<div class="fragment"><pre class="fragment">curl --data-binary @- -X POST --dump - "http://localhost:8529/_api/import?collection=test&amp;createCollection=true"
[ "firstName", "lastName", "age", "gender" ]
[ "Joe", "Public", 42, "male" ]
[ "Jane", "Doe", 31, "female" ]
HTTP/1.1 201 Created
server: triagens GmbH High-Performance HTTP Server
connection: Keep-Alive
content-type: application/json; charset=utf-8
{"error":false,"created":2,"errors":0}
</pre></div><p>The server will again respond with an HTTP 201 if everything went well. The number of documents imported will be returned in the <code>created</code> attribute of the response. If any documents were skipped or incorrectly formatted, this will be returned in the <code>errors</code> attribute. </p>
</div></div>
</div></body></html>