mirror of https://gitee.com/bigwinds/arangodb
updated manual
This commit is contained in:
parent
d99fe65aba
commit
82b13a0451
|
@ -43,16 +43,17 @@ Note that this does not imply any restriction of the number of revisions of docu
|
|||
|
||||
Restrict the number of document to at most 10 documents:
|
||||
|
||||
arango> db.examples.ensureCapConstraint(10);
|
||||
{ "id" : "examples/934311", "type" : "cap", "size" : 10, "byteSize" : 0, "isNewlyCreated" : true }
|
||||
|
||||
arango> for (var i = 0; i < 20; ++i) { var d = db.examples.save( { n : i } ); }
|
||||
|
||||
arango> db.examples.count();
|
||||
10
|
||||
```
|
||||
arangosh> db.examples.ensureCapConstraint(10);
|
||||
{ "id" : "examples/934311", "type" : "cap", "size" : 10, "byteSize" : 0, "isNewlyCreated" : true }
|
||||
|
||||
arangosh> for (var i = 0; i < 20; ++i) { var d = db.examples.save( { n : i } ); }
|
||||
|
||||
arangosh> db.examples.count();
|
||||
10
|
||||
```
|
||||
|
||||
<!--
|
||||
@anchor IndexCapShellEnsureCapConstraint
|
||||
@copydetails JSF_ArangoCollection_prototype_ensureCapConstraint
|
||||
-->
|
||||
-->
|
||||
|
|
|
@ -18,8 +18,10 @@ The minimum length of words that are indexed can be specified with the minWordLe
|
|||
|
||||
In case that the index was successfully created, the index identifier is returned.
|
||||
|
||||
arangod> db.emails.ensureFulltextIndex("body");
|
||||
{ "id" : "emails/42725508", "unique" : false, "type" : "fulltext", "fields" : ["body"], "isNewlyCreated" : true }
|
||||
```
|
||||
arangosh> db.emails.ensureFulltextIndex("body");
|
||||
{ "id" : "emails/42725508", "unique" : false, "type" : "fulltext", "fields" : ["body"], "isNewlyCreated" : true }
|
||||
```
|
||||
|
||||
<!--
|
||||
@anchor IndexFulltextShellEnsureFulltextIndex
|
||||
|
|
|
@ -38,64 +38,70 @@ In case that the index was successfully created, the index identifier is returne
|
|||
|
||||
Create an geo index for a list attribute:
|
||||
|
||||
arango> db.geo.ensureGeoIndex("loc");
|
||||
{ "id" : "geo/47772301", "type" : "geo1", "geoJson" : false, "fields" : ["loc"], "isNewlyCreated" : true }
|
||||
```
|
||||
arangosh> db.geo.ensureGeoIndex("loc");
|
||||
{ "id" : "geo/47772301", "type" : "geo1", "geoJson" : false, "fields" : ["loc"], "isNewlyCreated" : true }
|
||||
|
||||
arango> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.geo.save({ name : "Name/" + i + "/" + j,
|
||||
.......> loc: [ i, j ] });
|
||||
.......> }
|
||||
.......> }
|
||||
arangosh> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.geo.save({ name : "Name/" + i + "/" + j,
|
||||
.......> loc: [ i, j ] });
|
||||
.......> }
|
||||
.......> }
|
||||
|
||||
arango> db.geo.count();
|
||||
703
|
||||
arangosh> db.geo.count();
|
||||
703
|
||||
|
||||
arango> db.geo.near(0,0).limit(3).toArray();
|
||||
[ { "_id" : "geo/24861164", "_key" : "24861164", "_rev" : "24861164", "name" : "Name/0/0", "loc" : [ 0, 0 ]},
|
||||
{ "_id" : "geo/24926700", "_key" : "24926700", "_rev" : "24926700", "name" : "Name/0/10", "loc" : [ 0, 10 ]},
|
||||
{ "_id" : "geo/22436332", "_key" : "22436332", "_rev" : "22436332", "name" : "Name/-10/0", "loc" : [ -10, 0 ]}]
|
||||
|
||||
arango> db.geo.near(0,0).count();
|
||||
100
|
||||
arangosh> db.geo.near(0,0).limit(3).toArray();
|
||||
[
|
||||
{ "_id" : "geo/24861164", "_key" : "24861164", "_rev" : "24861164", "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : "geo/24926700", "_key" : "24926700", "_rev" : "24926700", "name" : "Name/0/10", "loc" : [ 0, 10 ] },
|
||||
{ "_id" : "geo/22436332", "_key" : "22436332", "_rev" : "22436332", "name" : "Name/-10/0", "loc" : [ -10, 0 ] }
|
||||
]
|
||||
|
||||
arangosh> db.geo.near(0,0).count();
|
||||
100
|
||||
```
|
||||
|
||||
Create an geo index for a hash array attribute:
|
||||
|
||||
```
|
||||
arangosh> db.geo2.ensureGeoIndex("location.latitude", "location.longitude");
|
||||
{ "id" : "geo2/1070652", "type" : "geo2", "fields" : ["location.latitude", "location.longitude"], "isNewlyCreated" : true }
|
||||
|
||||
arango> db.geo2.ensureGeoIndex("location.latitude", "location.longitude");
|
||||
{ "id" : "geo2/1070652", "type" : "geo2", "fields" : ["location.latitude", "location.longitude"], "isNewlyCreated" : true }
|
||||
arangosh> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.geo2.save({ name : "Name/" + i + "/" + j,
|
||||
.......> location: { latitude : i,
|
||||
.......> longitude : j } });
|
||||
.......> }
|
||||
.......> }
|
||||
|
||||
arango> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.geo2.save({ name : "Name/" + i + "/" + j,
|
||||
.......> location: { latitude : i,
|
||||
.......> longitude : j } });
|
||||
.......> }
|
||||
.......> }
|
||||
|
||||
arango> db.geo2.near(0,0).limit(3).toArray();
|
||||
[
|
||||
{
|
||||
"_id" : "geo2/72964588",
|
||||
"_key" : "72964588",
|
||||
"_rev" : "72964588",
|
||||
"location" : { "latitude" : 0, "longitude" : 0 },
|
||||
"name" : "Name/0/0"
|
||||
},
|
||||
{
|
||||
"_id" : "geo2/73030124",
|
||||
"_key" : "73030124",
|
||||
"_rev" : "73030124",
|
||||
"location" : { "latitude" : 0, "longitude" : 10 },
|
||||
"name" : "Name/0/10"
|
||||
},
|
||||
{
|
||||
"_id" : "geo2/70539756",
|
||||
"_key" : "70539756",
|
||||
"_rev" : "70539756",
|
||||
"location" : { "latitude" : -10, "longitude" : 0 },
|
||||
"name" : "Name/-10/0"
|
||||
}
|
||||
]
|
||||
arangosh> db.geo2.near(0,0).limit(3).toArray();
|
||||
[
|
||||
{
|
||||
"_id" : "geo2/72964588",
|
||||
"_key" : "72964588",
|
||||
"_rev" : "72964588",
|
||||
"location" : { "latitude" : 0, "longitude" : 0 },
|
||||
"name" : "Name/0/0"
|
||||
},
|
||||
{
|
||||
"_id" : "geo2/73030124",
|
||||
"_key" : "73030124",
|
||||
"_rev" : "73030124",
|
||||
"location" : { "latitude" : 0, "longitude" : 10 },
|
||||
"name" : "Name/0/10"
|
||||
},
|
||||
{
|
||||
"_id" : "geo2/70539756",
|
||||
"_key" : "70539756",
|
||||
"_rev" : "70539756",
|
||||
"location" : { "latitude" : -10, "longitude" : 0 },
|
||||
"name" : "Name/-10/0"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
`collection.ensureGeoConstraint( location, ignore-null)`
|
||||
|
||||
|
@ -128,36 +134,42 @@ Returns a geo index object if an index was found. The near or within operators c
|
|||
*Examples*
|
||||
|
||||
Assume you have a location stored as list in the attribute home and a destination stored in the attribute work. Then you can use the geo operator to select which geo-spatial attributes (and thus which index) to use in a near query.
|
||||
|
||||
arango> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.complex.save({ name : "Name/" + i + "/" + j,
|
||||
.......> home : [ i, j ],
|
||||
.......> work : [ -i, -j ] });
|
||||
.......> }
|
||||
.......> }
|
||||
|
||||
arango> db.complex.near(0, 170).limit(5);
|
||||
exception in file '/simple-query' at 1018,5: a geo-index must be known
|
||||
```
|
||||
arangosh> for (i = -90; i <= 90; i += 10) {
|
||||
.......> for (j = -180; j <= 180; j += 10) {
|
||||
.......> db.complex.save({ name : "Name/" + i + "/" + j,
|
||||
.......> home : [ i, j ],
|
||||
.......> work : [ -i, -j ] });
|
||||
.......> }
|
||||
.......> }
|
||||
|
||||
arango> db.complex.ensureGeoIndex(""home"");
|
||||
arango> db.complex.near(0, 170).limit(5).toArray();
|
||||
[ { "_id" : "complex/74655276", "_key" : "74655276", "_rev" : "74655276", "name" : "Name/0/170", "home" : [ 0, 170 ], "work" : [ 0, -170 ] },
|
||||
{ "_id" : "complex/74720812", "_key" : "74720812", "_rev" : "74720812", "name" : "Name/0/180", "home" : [ 0, 180 ], "work" : [ 0, -180 ] },
|
||||
{ "_id" : "complex/77080108", "_key" : "77080108", "_rev" : "77080108", "name" : "Name/10/170", "home" : [ 10, 170 ], "work" : [ -10, -170 ] },
|
||||
{ "_id" : "complex/72230444", "_key" : "72230444", "_rev" : "72230444", "name" : "Name/-10/170", "home" : [ -10, 170 ], "work" : [ 10, -170 ] },
|
||||
{ "_id" : "complex/72361516", "_key" : "72361516", "_rev" : "72361516", "name" : "Name/0/-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ] } ]
|
||||
arangosh> db.complex.near(0, 170).limit(5);
|
||||
exception in file '/simple-query' at 1018,5: a geo-index must be known
|
||||
|
||||
arango> db.complex.geo("work").near(0, 170).limit(5);
|
||||
exception in file '/simple-query' at 1018,5: a geo-index must be known
|
||||
arangosh> db.complex.ensureGeoIndex(""home"");
|
||||
arangosh> db.complex.near(0, 170).limit(5).toArray();
|
||||
[
|
||||
{ "_id" : "complex/74655276", "_key" : "74655276", "_rev" : "74655276", "name" : "Name/0/170", "home" : [ 0, 170 ], "work" : [ 0, -170 ] },
|
||||
{ "_id" : "complex/74720812", "_key" : "74720812", "_rev" : "74720812", "name" : "Name/0/180", "home" : [ 0, 180 ], "work" : [ 0, -180 ] },
|
||||
{ "_id" : "complex/77080108", "_key" : "77080108", "_rev" : "77080108", "name" : "Name/10/170", "home" : [ 10, 170 ], "work" : [ -10, -170 ] },
|
||||
{ "_id" : "complex/72230444", "_key" : "72230444", "_rev" : "72230444", "name" : "Name/-10/170", "home" : [ -10, 170 ], "work" : [ 10, -170 ] },
|
||||
{ "_id" : "complex/72361516", "_key" : "72361516", "_rev" : "72361516", "name" : "Name/0/-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ] }
|
||||
]
|
||||
|
||||
arango> db.complex.ensureGeoIndex("work");
|
||||
arango> db.complex.geo("work").near(0, 170).limit(5).toArray();
|
||||
[ { "_id" : "complex/72427052", "_key" : "72427052", "_rev" : "72427052", "name" : "Name/0/-170", "home" : [ 0, -170 ], "work" : [ 0, 170 ] },
|
||||
{ "_id" : "complex/72361516", "_key" : "72361516", "_rev" : "72361516", "name" : "Name/0/-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ] },
|
||||
{ "_id" : "complex/70002220", "_key" : "70002220", "_rev" : "70002220", "name" : "Name/-10/-170", "home" : [ -10, -170 ], "work" : [ 10, 170 ] },
|
||||
{ "_id" : "complex/74851884", "_key" : "74851884", "_rev" : "74851884", "name" : "Name/10/-170", "home" : [ 10, -170 ], "work" : [ -10, 170 ] },
|
||||
{ "_id" : "complex/74720812", "_key" : "74720812", "_rev" : "74720812", "name" : "Name/0/180", "home" : [ 0, 180 ], "work" : [ 0, -180 ] } ]
|
||||
arangosh> db.complex.geo("work").near(0, 170).limit(5);
|
||||
exception in file '/simple-query' at 1018,5: a geo-index must be known
|
||||
|
||||
arangosh> db.complex.ensureGeoIndex("work");
|
||||
arangosh> db.complex.geo("work").near(0, 170).limit(5).toArray();
|
||||
[
|
||||
{ "_id" : "complex/72427052", "_key" : "72427052", "_rev" : "72427052", "name" : "Name/0/-170", "home" : [ 0, -170 ], "work" : [ 0, 170 ] },
|
||||
{ "_id" : "complex/72361516", "_key" : "72361516", "_rev" : "72361516", "name" : "Name/0/-180", "home" : [ 0, -180 ], "work" : [ 0, 180 ] },
|
||||
{ "_id" : "complex/70002220", "_key" : "70002220", "_rev" : "70002220", "name" : "Name/-10/-170", "home" : [ -10, -170 ], "work" : [ 10, 170 ] },
|
||||
{ "_id" : "complex/74851884", "_key" : "74851884", "_rev" : "74851884", "name" : "Name/10/-170", "home" : [ 10, -170 ], "work" : [ -10, 170 ] },
|
||||
{ "_id" : "complex/74720812", "_key" : "74720812", "_rev" : "74720812", "name" : "Name/0/180", "home" : [ 0, 180 ], "work" : [ 0, -180 ] }
|
||||
]
|
||||
```
|
||||
|
||||
`collection.near( latitude, longitude)`
|
||||
|
||||
|
@ -185,18 +197,24 @@ This will add an attribute name to all documents returned, which contains the di
|
|||
*Examples*
|
||||
|
||||
To get the nearst two locations:
|
||||
|
||||
arango> db.geo.near(0,0).limit(2).toArray();
|
||||
[ { "_id" : "geo/24773376", "_key" : "24773376", "_rev" : "24773376", "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : "geo/22348544", "_key" : "22348544", "_rev" : "22348544", "name" : "Name/-10/0", "loc" : [ -10, 0 ] } ]
|
||||
|
||||
```
|
||||
arangosh> db.geo.near(0,0).limit(2).toArray();
|
||||
[
|
||||
{ "_id" : "geo/24773376", "_key" : "24773376", "_rev" : "24773376", "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : "geo/22348544", "_key" : "22348544", "_rev" : "22348544", "name" : "Name/-10/0", "loc" : [ -10, 0 ] }
|
||||
]
|
||||
```
|
||||
|
||||
If you need the distance as well, then you can use the distance operator:
|
||||
|
||||
arango> db.geo.near(0,0).distance().limit(2).toArray();
|
||||
[
|
||||
{ "_id" : geo/24773376", "_key" : "24773376", "_rev" : "24773376", "distance" : 0, "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : geo/22348544", "_key" : "22348544", "_rev" : "22348544", "distance" : 1111949.3, "name" : "Name/-10/0", "loc" : [ -10, 0 ] }
|
||||
]
|
||||
```
|
||||
arangosh> db.geo.near(0,0).distance().limit(2).toArray();
|
||||
[
|
||||
{ "_id" : geo/24773376", "_key" : "24773376", "_rev" : "24773376", "distance" : 0, "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : geo/22348544", "_key" : "22348544", "_rev" : "22348544", "distance" : 1111949.3, "name" : "Name/-10/0", "loc" : [ -10, 0 ] }
|
||||
]
|
||||
```
|
||||
|
||||
`collection.within( latitude, longitude, radius)`
|
||||
|
||||
|
@ -216,13 +234,17 @@ This will add an attribute name to all documents returned, which contains the di
|
|||
|
||||
To find all documents within a radius of 2000 km use:
|
||||
|
||||
arango> db.geo.within(0, 0, 2000 * 1000).distance().toArray();
|
||||
[ { "_id" : "geo/24773376", "_key" : "24773376", "_rev" : "24773376", "distance" : 0, "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : "geo/24707840", "_key" : "24707840", "_rev" : "24707840", "distance" : 1111949.3, "name" : "Name/0/-10", "loc" : [ 0, -10 ] },
|
||||
{ "_id" : "geo/24838912", "_key" : "24838912", "_rev" : "24838912", "distance" : 1111949.3, "name" : "Name/0/10", "loc" : [ 0, 10 ] },
|
||||
{ "_id" : "geo/22348544", "_key" : "22348544", "_rev" : "22348544", "distance" : 1111949.3, "name" : "Name/-10/0", "loc" : [ -10, 0 ] },
|
||||
{ "_id" : "geo/27198208", "_key" : "27198208", "_rev" : "27198208", "distance" : 1111949.3, "name" : "Name/10/0", "loc" : [ 10, 0 ] },
|
||||
{ "_id" : "geo/22414080", "_key" : "22414080", "_rev" : "22414080", "distance" : 1568520.6, "name" : "Name/-10/10", "loc" : [ -10, 10 ] },
|
||||
{ "_id" : "geo/27263744", "_key" : "27263744", "_rev" : "27263744", "distance" : 1568520.6, "name" : "Name/10/10", "loc" : [ 10, 10 ] },
|
||||
{ "_id" : "geo/22283008", "_key" : "22283008", "_rev" : "22283008", "distance" : 1568520.6, "name" : "Name/-10/-10", "loc" : [ -10, -10 ] },
|
||||
{ "_id" : "geo/27132672", "_key" : "27132672", "_rev" : "27132672", "distance" : 1568520.6, "name" : "Name/10/-10", "loc" : [ 10, -10 ] } ]
|
||||
```
|
||||
arangosh> db.geo.within(0, 0, 2000 * 1000).distance().toArray();
|
||||
[
|
||||
{ "_id" : "geo/24773376", "_key" : "24773376", "_rev" : "24773376", "distance" : 0, "name" : "Name/0/0", "loc" : [ 0, 0 ] },
|
||||
{ "_id" : "geo/24707840", "_key" : "24707840", "_rev" : "24707840", "distance" : 1111949.3, "name" : "Name/0/-10", "loc" : [ 0, -10 ] },
|
||||
{ "_id" : "geo/24838912", "_key" : "24838912", "_rev" : "24838912", "distance" : 1111949.3, "name" : "Name/0/10", "loc" : [ 0, 10 ] },
|
||||
{ "_id" : "geo/22348544", "_key" : "22348544", "_rev" : "22348544", "distance" : 1111949.3, "name" : "Name/-10/0", "loc" : [ -10, 0 ] },
|
||||
{ "_id" : "geo/27198208", "_key" : "27198208", "_rev" : "27198208", "distance" : 1111949.3, "name" : "Name/10/0", "loc" : [ 10, 0 ] },
|
||||
{ "_id" : "geo/22414080", "_key" : "22414080", "_rev" : "22414080", "distance" : 1568520.6, "name" : "Name/-10/10", "loc" : [ -10, 10 ] },
|
||||
{ "_id" : "geo/27263744", "_key" : "27263744", "_rev" : "27263744", "distance" : 1568520.6, "name" : "Name/10/10", "loc" : [ 10, 10 ] },
|
||||
{ "_id" : "geo/22283008", "_key" : "22283008", "_rev" : "22283008", "distance" : 1568520.6, "name" : "Name/-10/-10", "loc" : [ -10, -10 ] },
|
||||
{ "_id" : "geo/27132672", "_key" : "27132672", "_rev" : "27132672", "distance" : 1568520.6, "name" : "Name/10/-10", "loc" : [ 10, -10 ] }
|
||||
]
|
||||
```
|
||||
|
|
|
@ -23,24 +23,26 @@ In case that the index was successfully created, the index identifier is returne
|
|||
|
||||
*Examples*
|
||||
|
||||
arango> db.four.ensureUniqueConstraint("a", "b.c");
|
||||
{ "id" : "four/1147445", "unique" : true, "type" : "hash", "fields" : ["a", "b.c"], "isNewlyCreated" : true }
|
||||
```
|
||||
arangosh> db.four.ensureUniqueConstraint("a", "b.c");
|
||||
{ "id" : "four/1147445", "unique" : true, "type" : "hash", "fields" : ["a", "b.c"], "isNewlyCreated" : true }
|
||||
|
||||
arangosh> db.four.save({ a : 1, b : { c : 1 } });
|
||||
{ "_id" : "four/1868341", "_key" : "1868341", "_rev" : "1868341" }
|
||||
|
||||
arangsh> db.four.save({ a : 1, b : { c : 1 } });
|
||||
JavaScript exception in file '(arango)' at 1,9: [ArangoError 1210: cannot save document]
|
||||
!db.four.save({ a : 1, b : { c : 1 } });
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document]
|
||||
at (arango):1:9
|
||||
|
||||
arango> db.four.save({ a : 1, b : { c : 1 } });
|
||||
{ "_id" : "four/1868341", "_key" : "1868341", "_rev" : "1868341" }
|
||||
|
||||
arango> db.four.save({ a : 1, b : { c : 1 } });
|
||||
JavaScript exception in file '(arango)' at 1,9: [ArangoError 1210: cannot save document]
|
||||
!db.four.save({ a : 1, b : { c : 1 } });
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document]
|
||||
at (arango):1:9
|
||||
|
||||
arango> db.four.save({ a : 1, b : { c : null } });
|
||||
{ "_id" : "four/2196021", "_key" : "2196021", "_rev" : "2196021" }
|
||||
|
||||
arango> db.four.save({ a : 1 });
|
||||
{ "_id" : "four/2196023", "_key" : "2196023", "_rev" : "2196023" }
|
||||
arangosh> db.four.save({ a : 1, b : { c : null } });
|
||||
{ "_id" : "four/2196021", "_key" : "2196021", "_rev" : "2196021" }
|
||||
|
||||
arangosh> db.four.save({ a : 1 });
|
||||
{ "_id" : "four/2196023", "_key" : "2196023", "_rev" : "2196023" }
|
||||
```
|
||||
|
||||
`ensureHashIndex(field1, field2, ..., fieldn)`
|
||||
|
||||
|
@ -52,17 +54,19 @@ In case that the index was successfully created, the index identifier is returne
|
|||
|
||||
*Examples*
|
||||
|
||||
arango> db.test.ensureHashIndex("a");
|
||||
{ "id" : "test/5922391", "unique" : false, "type" : "hash", "fields" : ["a"], "isNewlyCreated" : true }
|
||||
```
|
||||
arangosh> db.test.ensureHashIndex("a");
|
||||
{ "id" : "test/5922391", "unique" : false, "type" : "hash", "fields" : ["a"], "isNewlyCreated" : true }
|
||||
|
||||
arangosh> db.test.save({ a : 1 });
|
||||
{ "_id" : "test/6381143", "_key" : "6381143", "_rev" : "6381143" }
|
||||
|
||||
arango> db.test.save({ a : 1 });
|
||||
{ "_id" : "test/6381143", "_key" : "6381143", "_rev" : "6381143" }
|
||||
arangosh> db.test.save({ a : 1 });
|
||||
{ "_id" : "test/6446679", "_key" : "6446679", "_rev" : "6446679" }
|
||||
|
||||
arango> db.test.save({ a : 1 });
|
||||
{ "_id" : "test/6446679", "_key" : "6446679", "_rev" : "6446679" }
|
||||
|
||||
arango> db.test.save({ a : null });
|
||||
{ "_id" : "test/6708823", "_key" : "6708823", "_rev" : "6708823" }
|
||||
arangosh> db.test.save({ a : null });
|
||||
{ "_id" : "test/6708823", "_key" : "6708823", "_rev" : "6708823" }
|
||||
```
|
||||
|
||||
<!--
|
||||
@anchor IndexHashShellEnsureUniqueConstraint
|
||||
|
@ -72,4 +76,4 @@ In case that the index was successfully created, the index identifier is returne
|
|||
@anchor IndexHashShellEnsureHashIndex
|
||||
@copydetails JSF_ArangoCollection_prototype_ensureHashIndex
|
||||
|
||||
-->
|
||||
-->
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
!SECTION Index basics
|
||||
|
||||
Indexes allow fast access to documents, provided the indexed attribute(s)
|
||||
are used in a query. While ArangoDB automatically indexes some system
|
||||
attributes, users are free to create extra indexes on non-system attributes
|
||||
of documents.
|
||||
|
||||
A user-defined index is created on collection level. Most user-defined indexes
|
||||
can be created by specifying the names of the attributes which should be indexed.
|
||||
Some index types allow indexing just one attribute (e.g. fulltext index) whereas
|
||||
other index types allow indexing multiple attributes at the same time.
|
||||
|
||||
The system attributes `_id`, `_key`, `_from` and `-to` are automatically indexed
|
||||
by ArangoDB, without the user being required to create extra indexes for them.
|
||||
|
||||
Therefore, indexing `_id`, `_key`, `_rev`, `_from`, and `_to` in a user-defined
|
||||
index is often not required and is currently not supported by ArangoDB.
|
||||
|
||||
ArangoDB provides the following index types:
|
||||
|
||||
!SUBSECTION Primary Index
|
||||
|
||||
For each collection there will always be a *primary index* which is a hash index
|
||||
for the [document keys](../Glossary/README.html#document_key) (`_key` attribute)
|
||||
of all documents in the collection. The primary index allows quick selection
|
||||
of documents in the collection using either the `_key` or `_id` attributes.
|
||||
|
||||
There are also dedicated functions to find a document given its `_key` or `_id`
|
||||
that will always make use of the primary index:
|
||||
|
||||
```js
|
||||
db.collection.document("<document-key>");
|
||||
db._document("<document-id>");
|
||||
```
|
||||
|
||||
The primary index of a collection cannot be dropped or changed.
|
||||
|
||||
|
||||
!SUBSECTION Edges Index
|
||||
|
||||
Every [edge collection](../Glossary/README.html#edge_collection) also has an
|
||||
automatically created *edges index*. The edges index provides quick access to
|
||||
documents by either their `_from` or `_to` attributes. It can therefore be
|
||||
used to quickly find connections between vertex documents and is invoked when
|
||||
the connecting edges of a vertex are queried.
|
||||
|
||||
The edges index cannot be dropped or changed. Extra edges indexes cannot be
|
||||
created on other attributes or in non-edge collections.
|
||||
|
||||
There are also dedidacted functions to find edges given their `_from` or `_to`
|
||||
values that will always make use of the edges index:
|
||||
|
||||
```js
|
||||
db.collection.edges("<from-value>");
|
||||
db.collection.edges("<to-value>");
|
||||
db.collection.outEdges("<from-value>");
|
||||
db.collection.outEdges("<to-value>");
|
||||
db.collection.inEdges("<from-value>");
|
||||
db.collection.inEdges("<to-value>");
|
||||
```
|
||||
|
||||
!SUBSECTION Hash Index
|
||||
|
||||
A hash index can be used to quickly find documents with specific attribute values.
|
||||
The hash index is unsorted, so it supports equality lookups but no range queries.
|
||||
|
||||
A hash index can be created on one or multiple document attributes. A hash index will
|
||||
only be used by a query if all indexed attributes are present in the search condition,
|
||||
and if all attributes are compared using the equality (`==`) operator.
|
||||
|
||||
Hash indexes can optionally be declared to be unique, disallowing saving the same
|
||||
value in the indexed attribute.
|
||||
|
||||
Hash indexes are supported by AQL and several query functions, e.g. `byExample`,
|
||||
`firstExample` etc.
|
||||
|
||||
|
||||
!SUBSECTION Skiplist Index
|
||||
|
||||
A skiplist is a sorted index structure. They can be used to quickly find documents
|
||||
with specific attribute values but also support range queries. They can also be used
|
||||
for sorting in AQL.
|
||||
|
||||
A skiplist can be created on one or multiple document attributes.
|
||||
|
||||
Skiplists can optionally be declared to be unique, disallowing saving the same
|
||||
value in the indexed attribute.
|
||||
|
||||
Skiplists are supported by AQL and several query functions, e.g. `byExample`,
|
||||
`firstExample` etc.
|
||||
|
||||
|
||||
!SUBSECTION Geo Index
|
||||
|
||||
A geo index is used to find places on the surface of the earth fast. The
|
||||
geo index in ArangoDB supports near and within queries. There are special functions
|
||||
to query geo indexes.
|
||||
|
||||
|
||||
!SUBSECTION Fulltext Index
|
||||
|
||||
A fulltext index can be used to find words, or prefixes of words inside documents.
|
||||
A fulltext index can be set on one attribute only, and will index all words contained
|
||||
in documents that have a textual value in this attribute. Only words with a (specifyable)
|
||||
minimum length are indexed. Word tokenization is done using the word boundary analysis
|
||||
provided by libicu, which is taking into account the selected language provided at
|
||||
server start. Words are indexed in their lower-cased form. The index supports complete
|
||||
match queries (full words) and prefix queries.
|
||||
|
||||
|
||||
!SECTION Index Identifiers and Handles
|
||||
|
||||
An *index handle* uniquely identifies an index in the database. It is a string and
|
||||
consists of the collection name and an *index identifier* separated by a `/`. The
|
||||
index identifier part is a numeric value that is auto-generated by ArangoDB.
|
||||
|
||||
A specific index of a collection can be accessed using its *index handle* or
|
||||
*index identifier* as follows:
|
||||
|
||||
```js
|
||||
db.collection.index("<index-handle>");
|
||||
db.collection.index("<index-identifier>");
|
||||
db._index("<index-handle>");
|
||||
```
|
||||
|
||||
For example: Assume that the index handle, which is stored in the `_id`
|
||||
attribute of the index, is `demo/362549736` and the index was created in a collection
|
||||
named `demo`. Then this index can be accessed as:
|
||||
|
||||
```js
|
||||
db.demo.index("demo/362549736");
|
||||
```
|
||||
|
||||
Because the index handle is unique within the database, you can leave out the
|
||||
*collection* and use the shortcut:
|
||||
|
||||
```js
|
||||
db._index("demo/362549736");
|
||||
```
|
||||
|
||||
!SECTION Which Index type to use when
|
||||
|
||||
ArangoDB automatically indexes the `_key` attribute in each collection. There
|
||||
is no need to index this attribute separately. Please note that a document's
|
||||
`_id` attribute is derived from the `_key` attribute, and is thus implicitly
|
||||
indexed, too.
|
||||
|
||||
ArangoDB will also automatically create an index on `_from` and `_to` in any
|
||||
edge collection, meaning incoming and outgoing connections can be determined
|
||||
efficiently.
|
||||
|
||||
Users can define additional indexes on one or multiple document attributes.
|
||||
Several different index types are provided by ArangoDB. These indexes have
|
||||
different usage scenarios:
|
||||
|
||||
- hash index: provides quick access to individual documents if (and only if)
|
||||
all indexed attributes are provided in the search query. The index will only
|
||||
be used for equality comparisons. It does not support range queries and
|
||||
cannot be used for sorting..
|
||||
|
||||
The hash index is a good candidate if all or most queries on the indexed
|
||||
attribute(s) are equality comparisons. It will be the most efficient index
|
||||
type if the index is declared unique.
|
||||
|
||||
Insertions into a non-unique hash index are also very efficent. Removal
|
||||
performance in a non-unique hash index depends on how often the indexed
|
||||
attribute's values repeat. If there are a lot of value repetitions, the
|
||||
removal performance in a non-unique hash index will suffer.
|
||||
|
||||
A non-unique hash index should there not be used if duplicate index values
|
||||
are allowed (i.e. when the hash index is not declared *unique*) and there
|
||||
will be many duplicate values in the index plus a lot of document removal
|
||||
operations in the collection.
|
||||
|
||||
- skip list index: skip lists keep the indexed values in an order, so they can
|
||||
be used for equality lookups, range queries and for sorting. Skip list indexes
|
||||
will have a higher overhead than hash indexes but they are more general and
|
||||
allow more use cases (e.g. range queries). Additionally, they can be used
|
||||
for lower selectivity attributes, when non-unique hash indexes are not a
|
||||
good fit.
|
||||
|
||||
- geo index: the geo index provided by ArangoDB allows searching for documents
|
||||
within a radius around a two-dimensional earth coordinate (point), or to
|
||||
find documents with are closest to a point. Document coordinates can either
|
||||
be specified in two different document attributes or in a single attribute, e.g.
|
||||
|
||||
{ "latitude": 50.9406645, "longitude": 6.9599115 }
|
||||
|
||||
or
|
||||
|
||||
{ "coords": [ 50.9406645, 6.9599115 ] }
|
||||
|
||||
- fulltext index: a fulltext index can be used to index all words contained in
|
||||
a specific attribute of all documents in a collection. Only words with a
|
||||
(specifiable) minimum length are indexed. Word tokenization is done using
|
||||
the word boundary analysis provided by libicu, which is taking into account
|
||||
the selected language provided at server start.
|
||||
|
||||
The index supports complete match queries (full words) and prefix queries.
|
||||
|
||||
- cap constraint: the cap constraint provided by ArangoDB indexes documents
|
||||
not to speed up search queries, but to limit (cap) the number or size of
|
||||
documents in a collection.
|
||||
|
|
@ -1,158 +1,13 @@
|
|||
!CHAPTER Handling Indexes
|
||||
|
||||
!SUBSECTION Indexes, Identifiers, Handles
|
||||
|
||||
This is an introduction to ArangoDB's interface for indexes in general.
|
||||
There are special sections for
|
||||
|
||||
- [cap constraints](../IndexHandling/Cap.md)
|
||||
- [geo-spatial indexes](../IndexHandling/Geo.md)
|
||||
- [index basics](../IndexHandling/IndexBasics.md)
|
||||
- [working with indexes](../IndexHandling/WorkingWithIndexes.md)
|
||||
- [hash indexes](../IndexHandling/Hash.md)
|
||||
- [skip-lists](../IndexHandling/Skiplist.md)
|
||||
- [skiplists](../IndexHandling/Skiplist.md)
|
||||
- [fulltext indexes](../IndexHandling/Fulltext.md)
|
||||
- [geo-spatial indexes](../IndexHandling/Geo.md)
|
||||
- [cap constraints](../IndexHandling/Cap.md)
|
||||
|
||||
!SUBSUBSECTION Index
|
||||
|
||||
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 key](../Glossary/README.html#document_key) (_key attribute). This index cannot be dropped or changed.
|
||||
[edge collections](../Glossary/README.html#edge_collection) will also have an automatically created edges index, which cannot be modified. This index provides quick access to documents via the _from and _to attributes.
|
||||
|
||||
Most user-land indexes can be created by defining the names of the attributes which should be indexed. Some index types allow indexing just one attribute (e.g. fulltext index) whereas other index types allow indexing multiple attributes.
|
||||
|
||||
Indexing system attributes such as _id, _key, _from, and _to in user-defined indexes is not supported by any index type. Manually creating an index that relies on any of these attributes is unsupported.
|
||||
|
||||
!SUBSUBSECTION Index Handle
|
||||
An index handle uniquely identifies an index in the database. It is a string and consists of a collection name and an index identifier separated by /.
|
||||
|
||||
!SUBSUBSECTION Geo Index
|
||||
|
||||
A geo index is used to find places on the surface of the earth fast.
|
||||
|
||||
!SUBSUBSECTION Hash Index
|
||||
|
||||
A hash index is used to find documents based on examples. A hash index can be created for one or multiple document attributes.
|
||||
A hash index will only be used by queries if all indexed attributes are present in the example or search query, and if all attributes are compared using the equality (== operator). That means the hash index does not support range queries.
|
||||
|
||||
If the index is declared unique, then access to the indexed attributes should be fast. The performance degrades if the indexed attribute(s) contain(s) only very few distinct values.
|
||||
|
||||
!SUBSUBSECTION Edges Index
|
||||
|
||||
An edges index is automatically created for edge collections. It contains connections between vertex documents and is invoked when the connecting edges of a vertex are queried. There is no way to explicitly create or delete edge indexes.
|
||||
|
||||
!SUBSUBSECTION Skiplist Index
|
||||
|
||||
A skiplist is used to find ranges of documents.
|
||||
|
||||
!SUBSUBSECTION Fulltext Index
|
||||
|
||||
A fulltext index can be used to find words, or prefixes of words inside documents. A fulltext index can be set on one attribute only, and will index all words contained in documents that have a textual value in this attribute. Only words with a (specifyable) minimum length are indexed. Word tokenisation is done using the word boundary analysis provided by libicu, which is taking into account the selected language provided at server start. Words are indexed in their lower-cased form. The index supports complete match queries (full words) and prefix queries.
|
||||
|
||||
!SECTION Address and ETag of an Index
|
||||
|
||||
All indexes in ArangoDB have an index handle. This handle uniquely defines an
|
||||
index and is managed by ArangoDB. The interface allows you to access the indexes
|
||||
of a collection as:
|
||||
|
||||
db.collection.index(index-handle)
|
||||
|
||||
For example: Assume that the index handle, which is stored in the *_id*
|
||||
attribute of the index, is *demo/362549736* and the index lives in a collection
|
||||
named *demo*, then that index can be accessed as:
|
||||
|
||||
db.demo.index("demo/362549736")
|
||||
|
||||
Because the index handle is unique within the database, you can leave out the
|
||||
*collection* and use the shortcut:
|
||||
|
||||
db._index("demo/362549736")
|
||||
|
||||
!SECTION Which Index type to use when
|
||||
|
||||
ArangoDB automatically indexes the *_key* attribute in each collection. There
|
||||
is no need to index this attribute separately. Please note that a document's
|
||||
*_id* attribute is derived from the *_key* attribute, and is thus implicitly
|
||||
indexed, too.
|
||||
|
||||
ArangoDB will also automatically create an index on *_from* and *_to* in any
|
||||
edge collection, meaning incoming and outgoing connections can be determined
|
||||
efficiently.
|
||||
|
||||
Users can define additional indexes on one or multiple document attributes.
|
||||
Several different index types are provided by ArangoDB. These indexes have
|
||||
different usage scenarios:
|
||||
|
||||
- hash index: provides quick access to individual documents if (and only if)
|
||||
all indexed attributes are provided in the search query. The index will only
|
||||
be used for equality comparisons. It does not support range queries.
|
||||
|
||||
The hash index is a good candidate if all or most queries on the indexed
|
||||
attribute(s) are equality comparisons, and if the attribute selectivity is
|
||||
high. That means the number of distinct attribute values in relation to the
|
||||
total number of documents should be high. This is the case for indexes
|
||||
declared *unique*.
|
||||
|
||||
The hash index should not be used if duplicate index values are allowed
|
||||
(i.e. if the hash index is not declared *unique*) and it cannot be avoided
|
||||
that there will be many duplicate index values. For example, it should be
|
||||
avoided to use a hash index on an attribute with just 10 distinct values in a
|
||||
collection with a million documents.
|
||||
|
||||
- skip list index: skip lists keep the indexed values in an order, so they can
|
||||
be used for equality and range queries. Skip list indexes will have a slightly
|
||||
higher overhead than hash indexes in case but they are more general and
|
||||
allow more use cases (e.g. range queries). Additionally, they can be used
|
||||
for lower selectivity attributes, when non-unique hash indexes are not a
|
||||
good fit.
|
||||
|
||||
- geo index: the geo index provided by ArangoDB allows searching for documents
|
||||
within a radius around a two-dimensional earth coordinate (point), or to
|
||||
find documents with are closest to a point. Document coordinates can either
|
||||
be specified in two different document attributes or in a single attribute, e.g.
|
||||
|
||||
```
|
||||
{ "latitude": 50.9406645, "longitude": 6.9599115 }
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
{ "coords": [ 50.9406645, 6.9599115 ] }
|
||||
```
|
||||
|
||||
- fulltext index: a fulltext index can be used to index all words contained in
|
||||
a specific attribute of all documents in a collection. Only words with a
|
||||
(specifiable) minimum length are indexed. Word tokenization is done using
|
||||
the word boundary analysis provided by libicu, which is taking into account
|
||||
the selected language provided at server start.
|
||||
|
||||
The index supports complete match queries (full words) and prefix queries.
|
||||
|
||||
- cap constraint: the cap constraint provided by ArangoDB indexes documents
|
||||
not to speed up search queries, but to limit (cap) the number or size of
|
||||
documents in a collection.
|
||||
|
||||
Currently it is not possible to index system attributes in user-defined indexes.
|
||||
|
||||
!SECTION Working with Indexes
|
||||
|
||||
!SUBSECTION Collection Methods
|
||||
|
||||
!SUBSECTION List of Index
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock collectionGetIndexes
|
||||
|
||||
!SUBSECTION Drop index
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock col_dropIndex
|
||||
|
||||
!SUBSECTION Existing index
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock collectionEnsureIndex
|
||||
|
||||
!SECTION Database Methods
|
||||
|
||||
!SUBSECTION Index handle
|
||||
<!-- js/server/modules/org/arangodb/arango-database.js -->
|
||||
@startDocuBlock IndexHandle
|
||||
|
||||
!SUBSECTION Drop index
|
||||
<!-- js/server/modules/org/arangodb/arango-database.js -->
|
||||
@startDocuBlock dropIndex
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
!SECTION Introduction to Skiplist Indexes
|
||||
|
||||
This is an introduction to ArangoDB's skip-lists.
|
||||
This is an introduction to ArangoDB's skiplists.
|
||||
|
||||
It is possible to define a skip-list index on one or more attributes (or paths)
|
||||
of a documents. This skip-list is then used in queries to locate documents
|
||||
within a given range. If the skip-list is unique, then no two documents are
|
||||
allowed to have the same set of attribute values.
|
||||
|
||||
!SECTION Accessing Skip-List Indexes from the Shell
|
||||
!SECTION Accessing Skiplist Indexes from the Shell
|
||||
|
||||
`ensureUniqueSkiplist(field1, field2, ..., fieldn)`
|
||||
|
||||
|
@ -18,40 +18,41 @@ Creates a skiplist index on all documents using attributes as paths to the field
|
|||
|
||||
In case that the index was successfully created, the index identifier is returned.
|
||||
|
||||
arangod> db.ids.ensureUniqueSkiplist("myId");
|
||||
{ "id" : "ids/42612360", "unique" : true, "type" : "skiplist", "fields" : ["myId"], "isNewlyCreated" : true }
|
||||
```
|
||||
arangosh> db.ids.ensureUniqueSkiplist("myId");
|
||||
{ "id" : "ids/42612360", "unique" : true, "type" : "skiplist", "fields" : ["myId"], "isNewlyCreated" : true }
|
||||
|
||||
arangosh> db.ids.save({ "myId": 123 });
|
||||
{ "_id" : "ids/42743432", "_key" : "42743432", "_rev" : "42743432" }
|
||||
arangosh> db.ids.save({ "myId": 456 });
|
||||
{ "_id" : "ids/42808968", "_key" : "42808968", "_rev" : "42808968" }
|
||||
arangosh> db.ids.save({ "myId": 789 });
|
||||
{ "_id" : "ids/42874504", "_key" : "42874504", "_rev" : "42874504" }
|
||||
|
||||
arangosh> db.ids.save({ "myId": 123 });
|
||||
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
!db.ids.save({ "myId": 123 });
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
at (arango):1:8
|
||||
|
||||
arangosh> db.ids.ensureUniqueSkiplist("name.first", "name.last");
|
||||
{ "id" : "ids/43362549", "unique" : true, "type" : "skiplist", "fields" : ["name.first", "name.last"], "isNewlyCreated" : true }
|
||||
|
||||
arangosh> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
|
||||
{ "_id" : "ids/43755765", "_rev" : "43755765", "_key" : "43755765" }
|
||||
arangosh> db.ids.save({ "name" : { "first" : "jens", "last": "jensen" }});
|
||||
{ "_id" : "ids/43821301", "_rev" : "43821301", "_key" : "43821301" }
|
||||
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "jensen" }});
|
||||
{ "_id" : "ids/43886837", "_rev" : "43886837", "_key" : "43886837" }
|
||||
|
||||
arangod> db.ids.save({ "myId": 123 });
|
||||
{ "_id" : "ids/42743432", "_key" : "42743432", "_rev" : "42743432" }
|
||||
arangod> db.ids.save({ "myId": 456 });
|
||||
{ "_id" : "ids/42808968", "_key" : "42808968", "_rev" : "42808968" }
|
||||
arangod> db.ids.save({ "myId": 789 });
|
||||
{ "_id" : "ids/42874504", "_key" : "42874504", "_rev" : "42874504" }
|
||||
|
||||
arangod> db.ids.save({ "myId": 123 });
|
||||
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
!db.ids.save({ "myId": 123 });
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
at (arango):1:8
|
||||
|
||||
|
||||
arangod> db.ids.ensureUniqueSkiplist("name.first", "name.last");
|
||||
{ "id" : "ids/43362549", "unique" : true, "type" : "skiplist", "fields" : ["name.first", "name.last"], "isNewlyCreated" : true }
|
||||
|
||||
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
|
||||
{ "_id" : "ids/43755765", "_rev" : "43755765", "_key" : "43755765" }
|
||||
arangod> db.ids.save({ "name" : { "first" : "jens", "last": "jensen" }});
|
||||
{ "_id" : "ids/43821301", "_rev" : "43821301", "_key" : "43821301" }
|
||||
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "jensen" }});
|
||||
{ "_id" : "ids/43886837", "_rev" : "43886837", "_key" : "43886837" }
|
||||
|
||||
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
|
||||
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
!db.ids.save({"name" : {"first" : "hans", "last": "hansen" }});
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
at (arango):1:8
|
||||
arangosh> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
|
||||
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
!db.ids.save({"name" : {"first" : "hans", "last": "hansen" }});
|
||||
! ^
|
||||
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
|
||||
at (arango):1:8
|
||||
```
|
||||
|
||||
`ensureSkiplist(field1, field2, ..., fieldn)`
|
||||
|
||||
|
@ -59,20 +60,21 @@ Creates a multi skiplist index on all documents using attributes as paths to the
|
|||
|
||||
In case that the index was successfully created, the index identifier is returned.
|
||||
|
||||
arangod> db.names.ensureSkiplist("first");
|
||||
{ "id" : "names/42725508", "unique" : false, "type" : "skiplist", "fields" : ["first"], "isNewlyCreated" : true }
|
||||
|
||||
arangod> db.names.save({ "first" : "Tim" });
|
||||
{ "_id" : "names/42856580", "_key" : "42856580", "_rev" : "42856580" }
|
||||
arangod> db.names.save({ "first" : "Tom" });
|
||||
{ "_id" : "names/42922116", "_key" : "42922116", "_rev" : "42922116" }
|
||||
arangod> db.names.save({ "first" : "John" });
|
||||
{ "_id" : "names/42987652", "_key" : "42987652", "_rev" : "42987652" }
|
||||
arangod> db.names.save({ "first" : "Tim" });
|
||||
{ "_id" : "names/43053188", "_key" : "43053188", "_rev" : "43053188" }
|
||||
arangod> db.names.save({ "first" : "Tom" });
|
||||
{ "_id" : "names/43118724", "_key" : "43118724", "_rev" : "43118724" }
|
||||
```
|
||||
arangosh> db.names.ensureSkiplist("first");
|
||||
{ "id" : "names/42725508", "unique" : false, "type" : "skiplist", "fields" : ["first"], "isNewlyCreated" : true }
|
||||
|
||||
arangosh> db.names.save({ "first" : "Tim" });
|
||||
{ "_id" : "names/42856580", "_key" : "42856580", "_rev" : "42856580" }
|
||||
arangosh> db.names.save({ "first" : "Tom" });
|
||||
{ "_id" : "names/42922116", "_key" : "42922116", "_rev" : "42922116" }
|
||||
arangosh> db.names.save({ "first" : "John" });
|
||||
{ "_id" : "names/42987652", "_key" : "42987652", "_rev" : "42987652" }
|
||||
arangosh> db.names.save({ "first" : "Tim" });
|
||||
{ "_id" : "names/43053188", "_key" : "43053188", "_rev" : "43053188" }
|
||||
arangosh> db.names.save({ "first" : "Tom" });
|
||||
{ "_id" : "names/43118724", "_key" : "43118724", "_rev" : "43118724" }
|
||||
```
|
||||
|
||||
<!--
|
||||
@anchor IndexSkiplistShellEnsureUniqueSkiplist
|
||||
|
@ -81,4 +83,4 @@ In case that the index was successfully created, the index identifier is returne
|
|||
@CLEARPAGE
|
||||
@anchor IndexSkiplistShellEnsureSkiplist
|
||||
@copydetails JSF_ArangoCollection_prototype_ensureSkiplist
|
||||
-->
|
||||
-->
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
!CHAPTER Working with Indexes
|
||||
|
||||
!SECTION Collection Methods
|
||||
|
||||
!SUBSECTION Listing all indexes of a collection
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock collectionGetIndexes
|
||||
|
||||
!SUBSECTION Creating an index
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock collectionEnsureIndex
|
||||
|
||||
!SUBSECTION Dropping an index
|
||||
<!-- arangod/V8Server/v8-vocbase.cpp -->
|
||||
@startDocuBlock col_dropIndex
|
||||
|
||||
!SECTION Database Methods
|
||||
|
||||
!SUBSECTION Fetching an index by handle
|
||||
<!-- js/server/modules/org/arangodb/arango-database.js -->
|
||||
@startDocuBlock IndexHandle
|
||||
|
||||
!SUBSECTION Dropping an index
|
||||
<!-- js/server/modules/org/arangodb/arango-database.js -->
|
||||
@startDocuBlock dropIndex
|
|
@ -227,12 +227,14 @@
|
|||
<!-- 26 -->
|
||||
* [Administrating ArangoDB](AdministratingArango/README.md)
|
||||
<!-- 27 -->
|
||||
* [Handling Indexes](IndexHandling/README.md)
|
||||
* [Cap Constraint](IndexHandling/Cap.md)
|
||||
* [Geo Indexes](IndexHandling/Geo.md)
|
||||
* [Fulltext Indexes](IndexHandling/Fulltext.md)
|
||||
* [Hash Indexes](IndexHandling/Hash.md)
|
||||
* [Skip-Lists](IndexHandling/Skiplist.md)
|
||||
* [Indexing](IndexHandling/README.md)
|
||||
* [Index Basics](IndexHandling/IndexBasics.md)
|
||||
* [Working with Indexes](IndexHandling/WorkingWithIndexes.md)
|
||||
* [Hash Indexes](IndexHandling/Hash.md)
|
||||
* [Skiplists](IndexHandling/Skiplist.md)
|
||||
* [Fulltext Indexes](IndexHandling/Fulltext.md)
|
||||
* [Geo Indexes](IndexHandling/Geo.md)
|
||||
* [Cap Constraint](IndexHandling/Cap.md)
|
||||
<!-- 28 -->
|
||||
* [Datafile Debugger](DatafileDebugger/README.md)
|
||||
<!-- 29 -->
|
||||
|
|
|
@ -11,10 +11,10 @@ lightweight universal JavaScript unit testing framework.
|
|||
Assume that you have a test file containing
|
||||
|
||||
```js
|
||||
function aqlTestSuite () {
|
||||
function exampleTestSuite () {
|
||||
return {
|
||||
testSizeOfTestCollection : function () {
|
||||
assertEqual(5, 5);
|
||||
testSizeOfTestCollection : function () {
|
||||
assertEqual(5, 5);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,12 @@ return jsunity.done();
|
|||
|
||||
Then you can run the test suite using *jsunity.runTest*
|
||||
|
||||
```js
|
||||
unix> ju.runTest("test.js");
|
||||
```
|
||||
arangosh> require("jsunity").runTest("test.js");
|
||||
2012-01-28T19:10:23Z [10671] INFO Running aqlTestSuite
|
||||
2012-01-28T19:10:23Z [10671] INFO 1 test found
|
||||
2012-01-28T19:10:23Z [10671] INFO [PASSED] testSizeOfTestCollection
|
||||
2012-01-28T19:10:23Z [10671] INFO 1 test passed
|
||||
2012-01-28T19:10:23Z [10671] INFO 0 tests failed
|
||||
2012-01-28T19:10:23Z [10671] INFO 1 millisecond elapsed
|
||||
```
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue