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

219 lines
9.2 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 Indexes </h1> </div>
</div>
<div class="contents">
<div class="textblock"><p>This is an introduction to ArangoDB's Http interface for indexes in general. There are special sections for various index types.</p>
<hr/>
<ul>
<li>
<a class="el" href="HttpIndex.html">HTTP Interface for Indexes</a> <ul>
<li>
<a class="el" href="HttpIndex.html#HttpIndexIntro">Indexes</a> </li>
<li>
<a class="el" href="HttpIndex.html#HttpIndexResource">Address of an Index</a> </li>
<li>
<a class="el" href="HttpIndex.html#HttpIndexHttp">Working with Indexes using HTTP</a> <ul>
<li>
<a class="el" href="HttpIndex.html#HttpIndexRead">GET /_api/index/index-handle</a> </li>
<li>
<a class="el" href="HttpIndex.html#HttpIndexCreate">POST /_api/index?collection=collection-identifier</a> </li>
<li>
<a class="el" href="HttpIndex.html#HttpIndexDelete">DELETE /_api/index/index-handle</a> </li>
<li>
<a class="el" href="HttpIndex.html#HttpIndexReadAll">GET /_api/index?collection=index-handle</a> </li>
</ul>
</li>
</ul>
</li>
</ul>
<hr/>
<h2><a class="anchor" id="HttpIndexIntro"></a>
Indexes</h2>
<p><b>Index</b>: Indexes are used to allow fast access to documents. For each collection there is always the primary index which is a hash index for the document identifier. </p>
<p><b>Index Handle</b>: An index handle uniquely identifies an index in the database. It is a string and consists of a collection identifier and a index identifier separated by <code>/</code>. </p>
<p><b>Geo Index</b>: A geo index is used to find places on the surface of the earth fast. </p>
<p><b>Hash Index</b>: A hash index is used to find documents based on examples. </p>
<p><b>Skiplist Index</b>: A skiplist is used to find ranges of documents. </p>
<p><b>Priority Queue</b>: A priority queue based on an attribute of the documents. </p>
<p>The basic operations (create, read, update, delete) for documents are mapped to the standard HTTP methods (POST, GET, PUT, DELETE).</p>
<h2><a class="anchor" id="HttpIndexResource"></a>
Address of an Index</h2>
<p>All indexes in ArangoDB have an unique handle. This index handle identifies an index and is managed by ArangoDB. All indexes are found under the URI</p>
<p><code><a href="http://">http://</a><em>server</em>:<em>port</em>/_api/index/<em>index-handle</em></code></p>
<p>For example: Assume that the index handle is <code>7254820/63563528</code> then the URL of that index is:</p>
<p><code><a href="http://localhost:8529/_api/index/7254820/63563528">http://localhost:8529/_api/index/7254820/63563528</a></code></p>
<h2><a class="anchor" id="HttpIndexHttp"></a>
Working with Indexes using HTTP</h2>
<p><a class="anchor" id="HttpIndexRead"></a> <hr/>
<em>GET /_api/index</em> (reads an index)<hr/>
<br/>
<code><b>GET /_api/index/<em>index-handle</em></b></code></p>
<p>The result is an objects describing the index. It has at least the following attributes:</p>
<ul>
<li><code>id</code>: The identifier of the collection.</li>
</ul>
<ul>
<li><code>type</code>: The type of the collection.</li>
</ul>
<p>All other attributes are type-dependent.</p>
<p><b>Examples</b><br/>
</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/index/117843216/0
HTTP/1.1 200 OK
content-type: application/json
{
"code": 200,
"fields": [
"_id"
],
"id": "117843216/0",
"type": "primary",
"error": false
}
</pre></div> <p><a class="anchor" id="HttpIndexCreate"></a> <hr/>
<em>POST /_api/index</em> (creates an index)<hr/>
<br/>
<code><b>POST /_api/index?collection=<em>collection-identifier</em></b></code></p>
<p>Creates a new index in the collection <em>collection-identifier</em>. Expects an object containing the index details.</p>
<p>See <a class="el" href="IndexCapHttp.html">Accessing Cap Constraints via Http</a>, <a class="el" href="IndexGeoHttp.html">Accessing Geo Indexes via Http</a>, <a class="el" href="IndexHashHttp.html">Accessing Hash Indexes via Http</a>, and <a class="el" href="IndexSkiplistHttp.html">Accessing Skip-List Indexes via Http</a> for details. By default, non-unique indexes will be created. To change this, use the <code>unique</code> attribute in the index details and set its value to <code>true</code>.</p>
<p>If the index does not already exists and could be created, then a <code>HTTP 201</code> is returned. If the index already exists, then a <code>HTTP 200</code> is returned.</p>
<p>If the <em>collection-identifier</em> is unknown, then a <code>HTTP 404</code> is returned. It is possible to specify a name instead of an identifier.</p>
<p><b>Examples</b><br/>
</p>
<p>Creating an unique constraint:</p>
<div class="fragment"><pre class="fragment">&gt; curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=102901008
{ "type" : "hash", "unique" : true, "fields" : [ "a", "b" ] }
HTTP/1.1 201 Created
content-type: application/json
{
"code": 201,
"fields": [
"a",
"b"
],
"id": "102901008/168054969",
"type": "hash",
"isNewlyCreated": true,
"unique": true,
"error": false
}
</pre></div><p>Creating a hash index:</p>
<div class="fragment"><pre class="fragment">&gt; curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=105981200
{ "type" : "hash", "unique" : false, "fields" : [ "a", "b" ] }
HTTP/1.1 201 Created
content-type: application/json
{
"code": 201,
"fields": [
"a",
"b"
],
"id": "105981200/171069625",
"type": "hash",
"isNewlyCreated": true,
"unique": false,
"error": false
}
</pre></div><p>Creating a skip-list:</p>
<div class="fragment"><pre class="fragment">&gt; curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=109061392
{ "type" : "skiplist", "unique" : false, "fields" : [ "a", "b" ] }
HTTP/1.1 201 Created
content-type: application/json
{
"code": 201,
"fields": [
"a",
"b"
],
"id": "109061392/173166777",
"type": "skiplist",
"isNewlyCreated": true,
"unique": false,
"error": false
}
</pre></div><p>Creating a unique skip-list:</p>
<div class="fragment"><pre class="fragment">&gt; curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=112141584
{ "type" : "skiplist", "unique" : true, "fields" : [ "a", "b" ] }
HTTP/1.1 201 Created
content-type: application/json
{
"code": 201,
"fields": [
"a",
"b"
],
"id": "112141584/175722681",
"type": "skiplist",
"isNewlyCreated": true,
"unique": true,
"error": false
}
</pre></div> <p><a class="anchor" id="HttpIndexDelete"></a> <hr/>
<em>DELETE /_api/index</em> (deletes an index)<hr/>
<br/>
<code><b>DELETE /_api/index/<em>index-handle</em></b></code></p>
<p>Deletes an index with <em>index-handle</em>.</p>
<p><b>Examples</b><br/>
</p>
<div class="fragment"><pre class="fragment">&gt; curl -X DELETE --dump - http://localhost:8529/_api/index/180506809/181424313
HTTP/1.1 200 OK
content-type: application/json
{
"code": 200,
"id": "180506809/181424313",
"error": false
}
</pre></div> <p><a class="anchor" id="HttpIndexReadAll"></a> <hr/>
<em>GET /_api/index</em> (reads all indexes of a collection)<hr/>
<br/>
<code><b>GET /_api/index?collection=<em>collection-identifier</em></b></code></p>
<p>Returns an object with an attribute <code>indexes</code> containing a list of all index descriptions for the given collection. The same information is also available in the <code>identifiers</code> as hash map with the index handle as keys.</p>
<p><b>Examples</b><br/>
</p>
<p>Return information about all indexes:</p>
<div class="fragment"><pre class="fragment">&gt; curl -X GET --dump - http://localhost:8529/_api/index?collection=115221776
HTTP/1.1 200 OK
content-type: application/json
{
"code": 200,
"indexes": [
{
"fields": [
"_id"
],
"id": "115221776/0",
"type": "primary"
}
],
"error": false,
"identifiers": {
"115221776/0": {
"fields": [
"_id"
],
"id": "115221776/0",
"type": "primary"
}
}
}
</pre></div> </div></div>
</div></body></html>