Skip to content

Commit 1d7a0ad

Browse files
Merge pull request #265746 from seesharprun/cosmos-remove-hyperlink-gremlin
Cosmos DB | Fix broken API for Gremlin hyperlink
2 parents d87e1be + 6736cc6 commit 1d7a0ad

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed
Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
11
---
2-
title: Access system document properties vian Azure Cosmos DB Graph
3-
description: Learn how read and write Azure Cosmos DB system document properties via API for Gremlin
2+
title: Access system document properties
3+
titleSuffix: Azure Cosmos DB for Apache Gremlin
4+
description: Learn how to read and write system document properties using Azure Cosmos DB for Apache Gremlin.
5+
author: seesharprun
6+
ms.author: sidandrews
7+
ms.reviewer: mansha
48
ms.service: cosmos-db
59
ms.subservice: apache-gremlin
610
ms.topic: how-to
7-
ms.date: 09/16/2021
8-
author: manishmsfte
9-
ms.author: mansha
11+
ms.date: 02/08/2024
1012
---
1113

12-
# System document properties
14+
# Access system document properties using Azure Cosmos DB for Apache Gremlin
15+
1316
[!INCLUDE[Gremlin](../includes/appliesto-gremlin.md)]
1417

15-
Azure Cosmos DB has [system properties](/rest/api/cosmos-db/databases) such as ```_ts```, ```_self```, ```_attachments```, ```_rid```, and ```_etag``` on every document. Additionally, Gremlin engine adds ```inVPartition``` and ```outVPartition``` properties on edges. By default, these properties are available for traversal. However, it's possible to include specific properties, or all of them, in Gremlin traversal.
18+
Azure Cosmos DB for Gremlin has [system properties](/rest/api/cosmos-db/databases) such as `_ts`, `_self`, `_attachments`, `_rid`, and `_etag` on every item. Additionally, Gremlin engine adds `inVPartition` and `outVPartition` properties on edges. By default, these properties are available for traversal. However, it's possible to include specific properties, or all of them, in Gremlin traversal.
1619

17-
```console
20+
```gremlin
1821
g.withStrategies(ProjectionStrategy.build().IncludeSystemProperties('_ts').create())
1922
```
2023

2124
## E-Tag
2225

23-
This property is used for optimistic concurrency control. If application needs to break operation into a few separate traversals, it can use eTag property to avoid data loss in concurrent writes.
26+
This property is used for optimistic concurrency control. If an application needs to break an operation into separate traversals, use the eTag property to avoid data loss in concurrent writes.
2427

25-
```console
28+
```gremlin
2629
g.withStrategies(ProjectionStrategy.build().IncludeSystemProperties('_etag').create()).V('1').has('_etag', '"00000100-0000-0800-0000-5d03edac0000"').property('test', '1')
2730
```
2831

2932
## Time-to-live (TTL)
3033

31-
If collection has document expiration enabled and documents have `ttl` property set on them, then this property will be available in Gremlin traversal as a regular vertex or edge property. `ProjectionStrategy` isn't necessary to enable time-to-live property exposure.
34+
If a graph has document expiration enabled and documents have `ttl` property set on them, then this property is available in Gremlin traversal as a regular vertex or edge property. `ProjectionStrategy` isn't necessary to enable time-to-live property exposure.
35+
36+
- Use the following command to set time-to-live on a new vertex:
3237

33-
* Use the following command to set time-to-live on a new vertex:
38+
```gremlin
39+
g.addV(<ID>).property('ttl', <expirationTime>)
40+
```
3441
35-
```console
36-
g.addV(<ID>).property('ttl', <expirationTime>)
37-
```
42+
For example, a vertex created with the following traversal is automatically deleted after *123 seconds*:
3843
39-
For example, a vertex created with the following traversal is automatically deleted after *123 seconds*:
44+
```gremlin
45+
g.addV('vertex-one').property('ttl', 123)
46+
```
4047
41-
```console
42-
g.addV('vertex-one').property('ttl', 123)
43-
```
48+
- Use the following command to set time-to-live on an existing vertex:
4449
45-
* Use the following command to set time-to-live on an existing vertex:
50+
```gremlin
51+
g.V().hasId(<ID>).has('pk', <pk>).property('ttl', <expirationTime>)
52+
```
4653
47-
```console
48-
g.V().hasId(<ID>).has('pk', <pk>).property('ttl', <expirationTime>)
49-
```
54+
- Applying the time-to-live property on vertices doesn't automatically apply it to associated edges. This behavior occurs because edges are independent records in the database store. Use the following command to set time-to-live on vertices and all the incoming and outgoing edges of the vertex:
5055
51-
* Applying time-to-live property on vertices does not automatically apply it to edges. Because edges are independent records in the database store. Use the following command to set time-to-live on vertices and all the incoming and outgoing edges of the vertex:
56+
```gremlin
57+
g.V().hasId(<ID>).has('pk', <pk>).as('v').bothE().hasNot('ttl').property('ttl', <expirationTime>)
58+
```
5259
53-
```console
54-
g.V().hasId(<ID>).has('pk', <pk>).as('v').bothE().hasNot('ttl').property('ttl', <expirationTime>)
55-
```
60+
> [!NOTE]
61+
> You can set time to Live (TTL) on the container to `-1` or to **On (no default)** from the Azure portal. Then, the TTL is infinite for any item unless the item has a TTL value explicitly set.
5662
57-
You can set TTL on the container to -1 or set it to **On (no default)** from Azure portal, then the TTL is infinite for any item unless the item has TTL value explicitly set.
63+
## Next step
5864
59-
## Next steps
60-
* [Azure Cosmos DB Optimistic Concurrency](../faq.yml#how-does-the-api-for-nosql-provide-concurrency-)
61-
* [Time to Live (TTL)](../time-to-live.md) in Azure Cosmos DB
65+
> [!div class="nextstepaction"]
66+
> [Time to Live (TTL) in Azure Cosmos DB](../time-to-live.md)

0 commit comments

Comments
 (0)