diff --git a/docs/Drivers/Java/Reference/Collection/Indexes.md b/docs/Drivers/Java/Reference/Collection/Indexes.md index 1aae17b31..88567464b 100644 --- a/docs/Drivers/Java/Reference/Collection/Indexes.md +++ b/docs/Drivers/Java/Reference/Collection/Indexes.md @@ -203,6 +203,49 @@ IndexEntity index = collection.ensurePersistentIndex(Arrays.asList("a", "b.c")); // the index has been created with the handle `index.getId()` ``` +## ArangoCollection.ensureTtlIndex + +`ArangoCollection.ensureTtlIndex(Iterable fields, TtlIndexOptions options) : IndexEntity` + +Creates a ttl index for the collection if it does not already exist. + +**Arguments** + +- **fields**: `Iterable` + + A list of attribute paths + +- **options**: `PersistentIndexOptions` + + - **name**: `String` + + Specify a custom name during index creation (optional). When running AQL queries you might then refer + to these name as your preferred index for lookups (e.g. Index Hints). + + - **expireAfter**: `Integer` + + The time (in seconds) after a document's creation after which the documents count as "expired". + + - **inBackground**: `Boolean` + + Indexes created with the 'inBackground' option, will not hold an exclusive collection + lock for the entire index creation period (rocksdb only). + +**Examples** + +```Java +ArangoDB arango = new ArangoDB.Builder().build(); +ArangoDatabase db = arango.db("myDB"); +ArangoCollection collection = db.collection("some-collection"); + +final TtlIndexOptions options = new TtlIndexOptions(); + options.name("myTtlIndex"); + options.expireAfter(3600); + +IndexEntity index = collection.ensureTtlIndex(Arrays.asList("a", "b.c"), options); +// the index has been created with the handle `index.getId()` +``` + ## ArangoCollection.getIndex `ArangoCollection.getIndex(String id) : IndexEntity`