Skip to content

added ttl index docu #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/Drivers/Java/Reference/Collection/Indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> fields, TtlIndexOptions options) : IndexEntity`

Creates a ttl index for the collection if it does not already exist.

**Arguments**

- **fields**: `Iterable<String>`

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`
Expand Down